-
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 f-string (UP032) can introduce a runtime error by misinterpreting \N in a raw string literal, where it is not an escape sequence. The fix in #21901 should not apply to raw strings. Example:
$ cat >up032.py <<'# EOF'
print(r"\N{angle}AOB = {angle}°".format(angle=180))
# EOF
$ python up032.py
\N180AOB = 180°
$ ruff --isolated check up032.py --select UP032 --fix
Found 1 error (1 fixed, 0 remaining).
$ cat up032.py
print(rf"\N{angle}AOB = {180}°")
$ python up032.py 2>&1 | tail -n 1
NameError: name 'angle' is not defined. Did you mean: 'range'?Version
ruff 0.14.10 (45bbb4c 2025-12-18)
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