`UP032` fix fails when braces are created via escapes
@IDrokin117 is already working on this.
Since Aug 8, 2025.
- Dominant language
- Rust
- Stars
- 49.7k
- Forks
- 2.4k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 458
Description
### Summary
The fix for [f-string (UP032)](https://docs.astral.sh/ruff/rules/f-string/#f-string-up032) will fail if the braces (`{` and `}`) are created via escapes instead of literal characters: [Example](https://play.ruff.rs/2a2c4778-a9ff-4499-b9cf-b89c38a25d4b)
```powershell
PS ~>echo '"\x7btest\x7d".format(test=1)' | uvx ruff check --select UP032 --fix -
"\x7btest\x7d"
Found 1 error (1 fixed, 0 remaining).
```
This does work properly with `.format` and could be fixed the same way as the non-cursed version:
```pycon
>>> "\x7btest\x7d".format(test=1)
'1'
>>> f"{1}"
'1'
```
This also applies to all the other ways of writing `{` and `}` non-literally (`\x`, `\u`, `\U`, `\N`)
### Version
ruff 0.12.7 (c5ac99889 2025-07-29)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.