-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using possibly undefined loop variable #440
Comments
So to be clear, if you run this on python 3 as is, you should get:
But this is not an issue with Python 2. Also if you add something like: value = None Prior to the for value in iterable: Then this doesn't error. As long as the context for how a variable is created is preserved (created as part of a for-loop for example, or on Python 3.8 with |
I obtain the same error in python2.
Sure, the whole point is that we should get a warning to add this declaration prior to the loop. No ? |
Pyflakes should report this as an error in python3, but in my testing (2.1.1 Python 3.7.2 on Darwin) it does not. I think this may be a regression. In python2 there won't be an error because |
collecting duplicates for "pyflakes doesn't do branch analysis" here: #715 |
In the code below, the variable
value
is possibly undefined. It would be nice to have a warning. For instance, Pylint gives the following one « W0631: Using possibly undefined loop variable 'value' (undefined-loop-variable) ».The text was updated successfully, but these errors were encountered: