F811 incorrectly triggered
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Pyflakes |
Fix Released
|
Low
|
Unassigned |
Bug Description
When doing work for oslo.messaging project, I've found behaviour that seems like a bug. You can find the code that triggered it at: https:/
When I run 'tox -e pep8' for the project with my patch applied (HEAD of the branch), I get the following:
[ihrachys@
GLOB sdist-make: /home/ihrachys/
pep8 inst-nodeps: /home/ihrachys/
pep8 runtests: commands[0] | flake8
./tests/
transport = messaging.
^
ERROR: InvocationError: '/home/
_______
ERROR: pep8: commands failed
It seems that pyflakes checker parses the file from top to bottom, checking possible violations in sequence. So it locates this new local variable 'transport' definition, and checks thru the list of globals where there is an import with the same name. The problem occurs because transport import is not used in this file BEFORE the variable definition, while it's still used AFTER it, in other classes. I guess the check should be triggered only if the import in question is never used anywhere else in the file, no matter where the usage is located in regards to redefinition.
The code in question is in checker.py, addBinding():
...
if (isinstance(
...
Changed in pyflakes: | |
status: | Fix Committed → Fix Released |
Thank you for this report.
The patch is commited, and it will be in 0.8.1 /github. com/pyflakes/ pyflakes/ commit/ ffe926c282bf787 37f8c34dff111cc bdab6c837b
https:/