Skip to content
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

False positive undefined-variable when a function attribute of same name is set #3877

Closed
Lucas-C opened this issue Oct 5, 2020 · 3 comments · Fixed by #5530
Closed

False positive undefined-variable when a function attribute of same name is set #3877

Lucas-C opened this issue Oct 5, 2020 · 3 comments · Fixed by #5530
Labels
Bug 🪲 C: undefined-variable Issues related to 'undefined-variable' check False Positive 🦟 A message is emitted but nothing is wrong with the code
Milestone

Comments

@Lucas-C
Copy link
Contributor

Lucas-C commented Oct 5, 2020

Steps to reproduce

CONDITION = None
FUNC = lambda: CONDITION
FUNC.CONDITION = 42

Pylint output:

pylint_bug_repro.py:2:15: E0602: Undefined variable 'CONDITION' (undefined-variable)

Current behavior

An "undefined variable" is incorrectly reported.

Expected behavior

Zero issue detected when defining a function attribute
with the same name of a local variable in the current scope.

pylint --version output

$ pylint --version
pylint 2.6.0
astroid 2.4.2
Python 3.7.7 (default, Apr 10 2020, 07:59:19)
[GCC 9.3.0]

Additional notes

There are a few other existing issues related to "false positive undefined-variable" errors:

@hippo91
Copy link
Contributor

hippo91 commented Oct 10, 2020

@Lucas-C thanks for this clear report!

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Dec 21, 2021

Thanks for the fix @Pierre-Sassoulas !

@Pierre-Sassoulas
Copy link
Member

I just reviewed ; @DanielNoord did the actual work 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 C: undefined-variable Issues related to 'undefined-variable' check False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants