You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test.py:8:41: F811 Redefinition of unused `glob` from line 6
|
6 | glob = 0
7 | assert g() == 0
8 | with nullcontext(enter_result=1) as glob:
| ^^^^ F811
9 | assert g() == 1
|
= help: Remove definition: `glob`
Found 1 error.
However, glob is used by g(), so neither of the assignments can be removed.
I’m aware that according to the Python documentation, “names listed in a global statement must not be defined as formal parameters, or as targets in with statements or except clauses, or in a for target list, class definition, function definition, import statement, or variable annotation”. However, that is currently not enforced by CPython or PyPy. There could be a ruff rule that reports an error in this case, but that’s a separate issue.
The text was updated successfully, but these errors were encountered:
With ruff 0.7.3:
However,
glob
is used byg()
, so neither of the assignments can be removed.I’m aware that according to the Python documentation, “names listed in a global statement must not be defined as formal parameters, or as targets in with statements or except clauses, or in a for target list, class definition, function definition, import statement, or variable annotation”. However, that is currently not enforced by CPython or PyPy. There could be a ruff rule that reports an error in this case, but that’s a separate issue.
The text was updated successfully, but these errors were encountered: