[Python-projects] W0631 - False positive (possibly undefined loop variable)

Paul `Satoshi' Hachmann satoshi.harada at gmail.com
Mon Dec 15 23:55:47 CET 2008


I believe I've encountered a false positive (W0631) - a minimal test case is:

-------------
for x in []:
    pass

for x in range(3):
    print (lambda : x)() # W0631 here
-------------

Note that removing the first loop, or using 'x' directly, rather than in a
lambda expression in the second, clears up the false positive.

It's not the same as #2463, since we're only ever using 'x' inside a loop
(where it obviously must be defined). It might be the same as #6015,
though.


Version information:
------------
pylint 0.15.2,
astng 0.17.2, common 0.34.0
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)]
------------


More information about the Python-Projects mailing list