You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Steps to reproduce
Consider the following example from the Python execution model reference here:
As per Python's documentation, executing this file will fail with the message
NameError: name 'a' is not defined
. (The class attributea
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
The text was updated successfully, but these errors were encountered: