Closed
Description
Steps to reproduce
Consider the following example from the Python execution model reference here:
class A:
a = 42
b = list(a + i for i in range(10))
As per Python's documentation, executing this file will fail with the message NameError: name 'a' is not defined
. (The class attribute a
is considered out of scope from within the body of the generator expression. As of Python3, it would also be out of scope from within the body of a list comprehension.)
Current behavior
Pylint assumes that the class attribute a
is visible from within the generator expression, and doesn't give a warning (i.e. a false negative).
Expected behavior
Pylint should print an undefined-variable
warning when attempting to access class attributes from within the body of a generator expression or comprehension.
pylint --version output
pylint 2.4.4
astroid 2.3.3
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
[GCC 7.3.0]
Metadata
Metadata
Assignees
Labels
No labels