Skip to content

nonlocal-without-binding (PLE0117)#

Derived from the Pylint linter.

What it does#

Checks for nonlocal names without bindings.

Why is this bad?#

nonlocal names must be bound to a name in an outer scope.

Example#

class Foo:
    def get_bar(self):
        nonlocal bar
        ...

Use instead:

class Foo:
    bar = 1

    def get_bar(self):
        nonlocal bar
        ...

References#