ruff
ruff copied to clipboard
f-string formatting: Consider format specs when choosing the preferred quotes
The new preview style formats
"" f'{1:""}'
as
f"{1:\"\"}"
This is correct but results in unnecessary escapes. I think we should account for the quotes in format-specs when choosing the preferred quotes for an f-string.
This can be changed here https://github.com/astral-sh/ruff/blob/113ce840a690cd59acbaf7d40d70b4352df681fe/crates/ruff_python_formatter/src/string/normalize.rs#L264-L295
CC: @dhruvmanila