Skip to content

UP032 fix doesn’t account for underscores in decimal int literals #21017

@dscorbett

Description

@dscorbett

Summary

The fix for f-string (UP032) parenthesizes decimal int literals when necessary to avoid syntax errors, except for literals containing underscores. Example:

$ cat >up032.py <<'# EOF'
print("{.real}".format(1_2))
# EOF

$ python up032.py
12

$ ruff --isolated check up032.py --select UP032 --diff 2>&1 | grep error:
error: Fix introduced a syntax error. Reverting all changes.

Version

ruff 0.14.1 (2bffef5 2025-10-16)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfixesRelated to suggested fixes for violationshelp wantedContributions especially welcome

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions