astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
31.35k stars 1.05k forks source link

Formatter ignores nested f-strings #13488

Open tylerlaprade opened 4 days ago

tylerlaprade commented 4 days ago

f'{ "\n".join([f"•{ k }" for k in [1,2,3]])}' My extra whitespace is not removed from this line.

MichaReiser commented 3 days ago

F-string formatting is a preview-only feature because we implemented it after the 2024 style guide was released.

Ruff removes the whitespace inside the expression when using ruff.format.preview = true (playground)

f'{"\n".join([f"•{k}" for k in [1, 2, 3]])}'