Skip to content

Formatter: multiline_string_handling preview style #8896

@MichaReiser

Description

@MichaReiser

Implement Black's multiline_string_handling as a preview style.

Ruff already implements (as part of stable) the new style when calling functions on a multiline string:

MULTILINE = """
foobar
""".replace(
    "\n", ""
)

Get's formatted to

MULTILINE = """
foobar
""".replace("\n", "")

However, Ruff doesn't yet implement the new style when passing a multiline string in a function call:

textwrap.dedent(
    """\
    This is a
    multiline string
"""
)

Gets formatted to:

textwrap.dedent("""\
    This is a
    multiline string
""")

Note: It's not yet decided if this style will make it into Black's 2024 stable style

Metadata

Metadata

Assignees

No one assigned

    Labels

    formatterRelated to the formatterpreviewRelated to preview mode features

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions