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

Invalid used-before-assignment #5112

Closed
socketpair opened this issue Oct 4, 2021 · 4 comments · Fixed by #5812
Closed

Invalid used-before-assignment #5112

socketpair opened this issue Oct 4, 2021 · 4 comments · Fixed by #5812
Labels
Assignment expression Related to the walrus operator / assignment expression C: used-before-assignment Issues related to 'used-before-assignment' check False Positive 🦟 A message is emitted but nothing is wrong with the code
Milestone

Comments

@socketpair
Copy link

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

@socketpair socketpair added Bug 🪲 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Oct 4, 2021
@cdce8p cdce8p added False Positive 🦟 A message is emitted but nothing is wrong with the code Assignment expression Related to the walrus operator / assignment expression and removed Bug 🪲 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Oct 4, 2021
@DanielNoord DanielNoord modified the milestone: 2.12.0 Oct 25, 2021
@socketpair
Copy link
Author

from random import randint

def asd():
    return [dom] if (dom := randint(-1, 2)) else []

The same

@cdce8p cdce8p added the C: used-before-assignment Issues related to 'used-before-assignment' check label Nov 17, 2021
@natgiordano
Copy link

Hi, I'd like to take a look at this issue.

@Pierre-Sassoulas
Copy link
Member

Neat, I assigned you to the issue, to not hesitate to ask for help here or in a draft merge request :)

@natgiordano
Copy link

Hey, could you actually unassign me from this issue? I meant to request #5187 and accidentally requested this. I went ahead and commented on #5187 like I initially intended to. Sorry for the confusion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Assignment expression Related to the walrus operator / assignment expression C: used-before-assignment Issues related to 'used-before-assignment' check False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
5 participants