-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix #5112: Prevent used-before-assignment
if named expression found first in container
#5812
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
Changes from 4 commits
ef78ee7
ee9426d
94dc95e
4a8816c
68179fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,3 +155,17 @@ def __init__(self, value): | |
|
||
|
||
dummy = Dummy(value=val if (val := 'something') else 'anything') | ||
|
||
def expression_in_ternary_operator_inside_container(): | ||
"""Named expression in ternary operator: inside container""" | ||
return [val2 if (val2 := 'something') else 'anything'] | ||
|
||
|
||
def expression_in_ternary_operator_inside_container_tuple(): | ||
"""Same case, using a tuple inside a 1-element list""" | ||
return [(val3, val3) if (val3 := 'something') else 'anything'] | ||
|
||
|
||
def expression_in_ternary_operator_inside_container_wrong_position(): | ||
"""2-element list where named expression comes too late""" | ||
return [val3, val3 if (val3 := 'something') else 'anything'] # [used-before-assignment] | ||
jacobtylerwalls marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pff... Man that's convoluted. Can't we raise an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Haha, I had to take 2-3mn and run the code to understand myself π But do we really want to make the kind of person that would write this, flock to our bug tracker to complain π ? |
Uh oh!
There was an error while loading. Please reload this page.