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

pylint does not recognize potential undefined variables #85

Closed
pylint-bot opened this issue Sep 28, 2013 · 3 comments · Fixed by #5384
Closed

pylint does not recognize potential undefined variables #85

pylint-bot opened this issue Sep 28, 2013 · 3 comments · Fixed by #5384
Labels
C: undefined-variable Issues related to 'undefined-variable' check Control flow Requires control flow understanding Enhancement ✨ Improvement to a component False Negative 🦋 No message is emitted but something is wrong with the code Hacktoberfest Help wanted 🙏 Outside help would be appreciated, good for new contributors High priority Issue with more than 10 reactions
Milestone

Comments

@pylint-bot
Copy link

Originally reported by: Mirko Dziadzka (BitBucket: mirkodziadzka, GitHub: @MirkoDziadzka?)


The following code should generate a warning, that the variable res may be undefined in the finally clause

#!python
try:
    # throw exception here to make res undefined
    res = 42
finally:
    print res

@pylint-bot
Copy link
Author

Original comment by Sylvain Thénault (BitBucket: sthenault, GitHub: @sthenault?):


see also issue #12

@dpinol
Copy link

dpinol commented Aug 26, 2019

this has been open 6 years. Is it on the roadmap?

thanks

@PCManticore PCManticore removed this from the 4.0 milestone Sep 26, 2019
@Pierre-Sassoulas Pierre-Sassoulas added the False Negative 🦋 No message is emitted but something is wrong with the code label Feb 7, 2021
@Pierre-Sassoulas Pierre-Sassoulas added the High priority Issue with more than 10 reactions label May 30, 2021
@Pierre-Sassoulas
Copy link
Member

Here's the test case actualized for python3:

try:
    # throw exception here to make res undefined
    res = 1 / 0
    res = 42
finally:
    print(res)

@dpinol this require control-flow which pylint does not have. Apparently no one worked on it yet, I'd be glad to review a merge request that fix this.

@Pierre-Sassoulas Pierre-Sassoulas added the Help wanted 🙏 Outside help would be appreciated, good for new contributors label Jul 1, 2021
@Pierre-Sassoulas Pierre-Sassoulas added this to the 4.0 milestone Aug 30, 2021
@DanielNoord DanielNoord added the C: undefined-variable Issues related to 'undefined-variable' check label Nov 18, 2021
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this issue Nov 24, 2021
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this issue Nov 24, 2021
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this issue Nov 25, 2021
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 4.0, 2.13.0 Nov 25, 2021
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this issue Dec 11, 2021
…final or except blocks where try statements could have failed
Pierre-Sassoulas pushed a commit that referenced this issue Dec 13, 2021
…atements could have failed (#5384)

* Emit `used-before-assignment` in final or except blocks where try statements could have failed

Fix #85, #2615
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: undefined-variable Issues related to 'undefined-variable' check Control flow Requires control flow understanding Enhancement ✨ Improvement to a component False Negative 🦋 No message is emitted but something is wrong with the code Hacktoberfest Help wanted 🙏 Outside help would be appreciated, good for new contributors High priority Issue with more than 10 reactions
Projects
None yet
5 participants