Skip to content

Normalize raw f-strings prefix #2171

@jamesmyatt

Description

@jamesmyatt

Is your feature request related to a problem? Please describe.

Black should normalize the prefix used for raw f-strings (https://www.python.org/dev/peps/pep-0498/#raw-f-strings). Both rf and fr work, but one should be preferred.

Currently, the following code is not changed:

    f = rf"hello {world}"
    f = fr"hello {world}"

Describe the solution you'd like

Pick one and normalize. I don't really care which. rf matches the name "raw f-string", but fr matches the example in PEP-498 and Jupyterlab syntax highlighting seems to prefer it.

Describe alternatives you've considered

Doing nothing leaves open the opportunity for inconsistency and disagreement.

Additional context

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    F: stringsRelated to our handling of stringsT: 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