-
Notifications
You must be signed in to change notification settings - Fork 2k
RUF010 fix should be unsafe when it deletes a comment #19745
Copy link
Copy link
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 explicit-f-string-type-conversion (RUF010) should be marked unsafe when it deletes a comment. Example:
$ cat >ruf010.py <<'# EOF'
f"{ascii(
# comment
1
)}"
# EOF
$ ruff --isolated check ruf010.py --select RUF010 --fix
Found 1 error (1 fixed, 0 remaining).
$ cat ruf010.py
f"{1!a}"When the modified code includes a comment and the comment is preserved, the fix should continue to be marked safe. Example:
f"{ascii((
# comment
1
))}"Version
ruff 0.12.7 (c5ac998 2025-07-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