Skip to content

used-before-assignment false negative after conditionals #1727

@eddieViscosity

Description

@eddieViscosity

Running pylint on this simple example does not detect that x can be used before assignment. This is a very common programming mistake and should be caught.

def a_function(d):
    if d:
        x=1
    return x

Current behavior - Fails to detect x is used before assignment

Expected behavior: detect variable use inside logic branches.

pylint --version output: pylint-2 1.7.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: used-before-assignmentIssues related to 'used-before-assignment' checkControl flowRequires control flow understandingEnhancement ✨Improvement to a componentFalse Negative 🦋No message is emitted but something is wrong with the codeHigh priorityIssue with more than 10 reactions

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions