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 negative used-before-assignment when variable is only defined in except clause #4761

Closed
gcolombeau opened this issue Jul 28, 2021 · 0 comments · Fixed by #5402
Closed
Labels
Bug 🪲 Control flow Requires control flow understanding False Negative 🦋 No message is emitted but something is wrong with the code

Comments

@gcolombeau
Copy link

gcolombeau commented Jul 28, 2021

Bug description

"""used-before-assignment (E0601)"""

def undefined_variable():
    """used-before-assignment (E0601)"""
    try:
        pass
    except ValueError:
        some_message = 'some message'

    if not some_message:
        return 1

    return some_message

Configuration

No response

Command used

pylint e0601.py

Pylint output

------------------------------------
Your code has been rated at 10.00/10

Expected behavior

Pylint should report used-before-assignment on lines 10 and 13.

Pylint version

pylint 2.9.5
astroid 2.6.5
Python 3.6.10 (default, Jan 31 2020, 10:49:38) 
[GCC 7.4.0]

OS / Environment

No response

Additional dependencies

No response

@gcolombeau gcolombeau added Bug 🪲 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jul 28, 2021
@gcolombeau gcolombeau changed the title False negative undefined-variable when variable is only defined in except clause False negative used-before-assignment when variable is only defined in except clause Jul 28, 2021
@Pierre-Sassoulas Pierre-Sassoulas added False Negative 🦋 No message is emitted but something is wrong with the code and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jul 28, 2021
@DanielNoord DanielNoord added the Control flow Requires control flow understanding label Oct 15, 2021
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this issue Nov 26, 2021
…nments only take place in except blocks
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this issue Nov 26, 2021
…nments only take place in except blocks
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this issue Nov 26, 2021
…nments only take place in except blocks
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this issue Nov 26, 2021
…nments only take place in except blocks
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this issue Dec 2, 2021
…nments only take place in except blocks
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this issue Dec 2, 2021
…nments only take place in except blocks
Pierre-Sassoulas added a commit that referenced this issue Dec 11, 2021
… made in except blocks (#5402)

Co-authored-by: Daniël van Noord <[email protected]>
Co-authored-by: Pierre Sassoulas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Control flow Requires control flow understanding False Negative 🦋 No message is emitted but something is wrong with the code
Projects
None yet
3 participants