You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to make your software package run with the python -O optimization, you might want to ensure that the code does not contain a walrus assignment in assert statements:
y=0assert (x:=y) isnotNonex=x+1
This code example runs fine normally, but if run with python -O the assertion gets removed and the program raises a UnboundLocalError because x is no longer bound.
As a developer, I might want to configure my linter in such a way that walrus assignments are not allowed in assertion statements. This way, I can enforce that the code will be compatible running with python -O.
The text was updated successfully, but these errors were encountered:
awaelchli
changed the title
Rule suggestion: Prevent usage of walrus assignments in assert statements
Rule suggestion: Prevent walrus assignments in assert statements
Sep 6, 2023
If you want to make your software package run with the
python -O
optimization, you might want to ensure that the code does not contain a walrus assignment inassert
statements:This code example runs fine normally, but if run with
python -O
the assertion gets removed and the program raises aUnboundLocalError
because x is no longer bound.As a developer, I might want to configure my linter in such a way that walrus assignments are not allowed in assertion statements. This way, I can enforce that the code will be compatible running with
python -O
.The text was updated successfully, but these errors were encountered: