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
In this example pyflakes reports a misleading location for an unused variable:
$ cat example.py
def foo():
exc = None
try:
print('foo')
except NameError as exc:
print(exc)
$ pyflakes example.py
example.py:5: local variable 'exc' is assigned to but never used
pyflakes reports exc on line 5 (the except line) as unused, which is misleading in my opinion since it's used within the exception handling. I guess that pyflakes recognizes that exc from line 2 (exc = None) as unused (which is unused actually), but determines line 5 as the last occuring declaration of exc.
The text was updated successfully, but these errors were encountered:
Note that this only errors in python3, probably due to the "new" exception scoping rules (except ... as e is roughly equivalent to that block of code; del e):
$ ./venv2/bin/pyflakes t.py
$ ./venv3/bin/pyflakes t.py
t.py:5: local variable 'exc' is assigned to but never used
note that the above code example in python3 will throw a NameError (global scope) or UnboundLocalError (function scope), at least for me in Py3.6.6, if you would actually use exc after that block
In this example pyflakes reports a misleading location for an unused variable:
pyflakes reports exc on line 5 (the except line) as unused, which is misleading in my opinion since it's used within the exception handling. I guess that pyflakes recognizes that exc from line 2 (exc = None) as unused (which is unused actually), but determines line 5 as the last occuring declaration of exc.
The text was updated successfully, but these errors were encountered: