-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
questionAsking for support or clarificationAsking for support or clarification
Description
Summary
The nonlocal statement requires that the variable is a local variable in one of the parent scopes. ruff does not check this. For example:
def no_local_var():
def setter(xx):
nonlocal x
x = xx
print(x)
return setter(playground link: https://play.ruff.rs/f6ca3be7-208f-4ade-b68e-148d3546af6b)
This passes all checks:
$ ruff check --isolated t2.py
All checks passed!
However this fails with a SyntaxError when run:
$ python t2.py
File "/home/eltoder/dev/scratch/t2.py", line 3
nonlocal x
^^^^^^^^^^
SyntaxError: no binding for nonlocal 'x' found
Version
0.14.5
Metadata
Metadata
Assignees
Labels
questionAsking for support or clarificationAsking for support or clarification