Erroneous 'list comprehension redefines' in Python 2.7 pyflakes 0.6.1
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Pyflakes |
Fix Released
|
Medium
|
Unassigned |
Bug Description
When updating from pyflakes 0.5.0 to pyflakes 0.6.1 many occurances of 'list comprehension redefines' are listed erroneously. The issue appears to be that pyflakes will complain about reusing the same loop variable name in multiple list comprehensions.
Here are two lines for example:
168:
wells = Well.objects.
...
183:
fx_wells = [well for well in wells if well.assay_subtype == fx_subtype]
And a message such as below appears.
foo/bar.py:183:: list comprehension redefines 'well' from line 168
In this case pyflakes should be smart enough to realize that 'well' will not be incorrectly used because it will be initialized immediately with the expected value in the second list comprehension.
Related branches
- Pyflakes Dev: Pending requested
-
Diff: 74 lines (+40/-5) (has conflicts)3 files modifiedNEWS.txt (+13/-4)
pyflakes/checker.py (+2/-1)
pyflakes/test/test_other.py (+25/-0)
Changed in pyflakes: | |
milestone: | none → 0.7 |
Changed in pyflakes: | |
status: | Fix Committed → Fix Released |
I couldn't reproduce this with the attached file.