Skip to content

Invalid used-before-assignment #5112

@socketpair

Description

@socketpair

Bug description

from random import randint

asd2 = {
    **({'param': x} if (x := randint(0, 1)) else {}),
}

Configuration

No response

Command used

pylint a.py

Pylint output

E0601: Using variable 'x' before assignment (used-before-assignment)

Expected behavior

no error.

Pylint version

pylint 2.9.6
astroid 2.6.6
Python 3.9.7 (default, Aug 30 2021, 00:00:00) 
[GCC 11.2.1 20210728 (Red Hat 11.2.1-1)]

OS / Environment

Fedora 34

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Assignment expressionRelated to the walrus operator / assignment expressionC: used-before-assignmentIssues related to 'used-before-assignment' checkFalse Positive 🦟A message is emitted but nothing is wrong with the code

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions