-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violationshelp wantedContributions especially welcomeContributions especially welcome
Description
Summary
The fix for unnecessary-assign (RET504) assumes that the first equals sign in the assignment statement is the one that does the assignment. However, if the first equals sign is in a comment, the fix can fail because of a syntax error. The fix should seek the first equals sign token, not the first equals sign character.
$ cat >ret504.py <<'# EOF'
def f():
(#=
x) = 1
return x
# EOF
$ ruff --isolated check ret504.py --select RET504 --unsafe-fixes --diff 2>&1 | grep error:
error: Fix introduced a syntax error. Reverting all changes.Version
ruff 0.11.12 (aee3af0 2025-05-29)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violationshelp wantedContributions especially welcomeContributions especially welcome