-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
False positive undefined-variable
for variable in inner scope matching outer scope type annotation
#5326
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
Comments
After bisecting, the change occurred in b1c4735. Reading that change, it seems |
undefined-variable
for variable in inner scope matching outer scope type annotationundefined-variable
for variable in inner scope matching unused outer scope type annotation
hello to pop in and say we have that issue but with the annotated outer scope variable name being used/assigned to later Basically something like: node: MyNode # triggers the undefined-variable which is hard to comprehend
list_of_nodes = [node for node in maybe_node_list if isinstance(node, MyNode)]
for node in other_list_of_node:
pass |
This also fails on the first line list_of_nodes = [node for node in maybe_node_list if isinstance(node, MyNode)]
node: MyNode
for node in other_list_of_node:
pass Edit: feels like it should not, we'll be freezing our pylint dependency to the previous version until this is fixed as it prevents from having proper typing for mypy and sensible code in those cases |
undefined-variable
for variable in inner scope matching unused outer scope type annotationundefined-variable
for variable in inner scope matching outer scope type annotation
… matching an outer scope type annotation Refs pylint-dev#5326
I broke the false negative out into #5654. That means this ticket is now just a false positive with a PR to close it. |
Bug description
Configuration
No response
Command used
Pylint output
a.py:3: [E0602(undefined-variable), func] Undefined variable 'a'
Expected behavior
No messages
Pylint version
OS / Environment
No response
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: