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
[#3791] propose a fix #4737
[#3791] propose a fix #4737
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look good thank you for the analysis, I have a small comment but this looks mergeable already.
pylint/checkers/variables.py
Outdated
@@ -1015,6 +1016,12 @@ def visit_name(self, node): | |||
self._loopvar_name(node, name) | |||
break | |||
|
|||
# the name has already been consumed, skip decorators | |||
if name in current_consumer.consumed and utils.is_func_decorator( | |||
current_consumer.node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be an or
line 1012 instead :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, moved
CONTRIBUTORS.txt
Outdated
@@ -1,4 +1,4 @@ | |||
ο»ΏContributors | |||
Contributors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a modification here, I don't know why ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a guess but I think my editor ate the byte order mark?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was it. Restored :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π
Thank you for the fix and congratulation on becoming a pylint contributor :) ! |
Steps
doc/whatsnew/<current release.rst>
.Description
This is a proposed fix for an issue where defining a function decorated with a list comprehension that shares argument name, and the argument is used twice in the list comprehension, it shows an undefined-variable error.
To put it in code:
This wrongfully shows an
undefined-variable
error since version at least 2.7.This is rightfully OK on the current
main
.This probably will need changes, but I am not familiar enough with the codebase to go better about it.
Type of Changes
Related Issue
Closes #3791