Skip to content

Formatter moves comments between f-string expr and format spec to invalid location #18730

@MeGaGiGaGon

Description

@MeGaGiGaGon

Summary

It looks like this case snuck though the latest f-string changes. playground this code is valid

f"{1
#test
:}"

But gets made invalid by the formatter

f"{
    1:
    # test
}"

(Or in the case of a multiline string, has behavior change)

Version

ruff 0.12.0 (87f0feb 2025-06-17) + playground

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingformatterRelated to the formatter

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions