[Fix error] C417 and walrus statements #14808
Labels
bug
Something isn't working
fixes
Related to suggested fixes for violations
help wanted
Contributions especially welcome
Applying fixes for rule C417 introduces a syntax error when the second
map
argument is a walrus assignment operator.Minimal example below.
I'm using
ruff
0.8.2 and Python 3.12.7 to test this.For a more complete example, this issue first arose in my solution to Advent of Code 2019 Day 3.
Fix applied by
ruff check test.py --select C417 --fix --unsafe-fixes
is syntactically incorrect
You would think wrapping the walrus statement in parentheses would suffice, like
And indeed,
ruff
believes all is wellbut this too, in fact, raises a syntax error
I wonder whether the real solution is to extract the assignment onto the previous line, or not show the warning in the first place.
The text was updated successfully, but these errors were encountered: