-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 empty-comment (PLR2044) deletes the entire physical line if there is nothing in the line but the comment. It should only do so when the physical line is its own logical line. When the previous line ends with a backslash, the fix should delete the comment but not the entire line, or it should delete the entire line plus the preceding backslash. Otherwise, it can change the program’s behavior. Example:
$ cat >plr2044.py <<'# EOF'
x = 0 \
#
+1
print(x)
# EOF
$ python plr2044.py
0
$ ruff --isolated check plr2044.py --select PLR2044 --fix
Found 1 error (1 fixed, 0 remaining).
$ python plr2044.py
1Version
ruff 0.12.3 (5bc81f2 2025-07-11)
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