-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Python: 3.12.3
Version: ruff 0.4.4
Command: ruff check --select W605 .\test.py --fix
And let's given the following code snippet in test.py:
total = 10
ok = 7
incomplete = 3
s = f"TOTAL: {total}\nOK: {ok}\INCOMPLETE: {incomplete}\n"
It is wrongly fixed as:
total = 10
ok = 7
incomplete = 3
s = rf"TOTAL: {total}\nOK: {ok}\INCOMPLETE: {incomplete}\n"
Now the string is a raw string. The newlines will then interpreted as literals and will not remain newlines.
If I do the same for a normal string:
s = "TOTAL: 10\nOK: 3\INCOMPLETE: 7\n"
It is correctly fixed as:
s = "TOTAL: 10\nOK: 3\\INCOMPLETE: 7\n"
The invalid escape sequence '\I' is correctly fixed as \\, and the newlines are still there.
Even if it is a f-string, but without placeholders, it is done correctly:
s = f"TOTAL: 10\nOK: 3\INCOMPLETE: 7\n"
Result is correct:
s = f"TOTAL: 10\nOK: 3\\INCOMPLETE: 7\n"
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working