Skip to content

[used-before-assignment] False negative for for/if/else/continue pattern #9379

Open
@jacobtylerwalls

Description

@jacobtylerwalls

Bug description

def halfway_safe():
    """Name used safely inside the loop, unsafely outside it."""
    for _temp in range(0, 1):
        try:
            pass
        except ValueError:
            error = True
        else:
            continue

        print(error)
    print(error)  # Should raise used-before-assignment

Configuration

No response

Command used

n/a

Pylint output

nothing

Expected behavior

used-before-assignment on last line

Pylint version

Caused in #9374 (accepted because we prefer false negatives to false positives)

OS / Environment

No response

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: used-before-assignmentIssues related to 'used-before-assignment' checkFalse Negative 🦋No message is emitted but something is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions