Skip to content

UP025 fix introduces a syntax error for an empty string followed by a u-prefixed string #18895

@dscorbett

Description

@dscorbett

Summary

The fix for unicode-kind-prefix (UP025) can introduce a syntax error when the prefixed string follows a non-triple-quoted empty string with the same kind of quotation marks without an intervening space. The fix should add a space if necessary.

Playground

$ cat >up025.py <<'# EOF'
""u""
# EOF

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

Version

ruff 0.12.0 (87f0feb 2025-06-17)

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