Skip to content

AST safety check fails to catch incorrect f-string change #4268

@kwk

Description

@kwk

Describe the style change

I wonder if f-strings should be formatted at all.

Examples in the current Black style

print(f"{"|".join(['a','b','c'])}")

Desired style

print(f"{"|".join(['a','b','c'])}")

Note

There's no change to the input here.

Additional context

Black formats the "|" to become " | " and that affects the output which cannot be desired.

Black formats the snippet like this currently:

print(f"{" | ".join(['a','b','c'])}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    T: bugSomething isn't workingT: styleWhat do we want Blackened code to look like?

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions