Skip to content

Add ability to disable multi-line string concatenation with ruff format #18436

@seanbudd

Description

@seanbudd

Summary

Please change ruff format's behaviour for concatenating multi-line strings.

For example:

outputFile.write(
	"</notes>\n"
	f"<segment>\n"
	f"<source>{xmlEscape(source)}</source>\n"
	"</segment>\n"
	"</unit>\n",
)

Should not concatenate to

outputFile.write(
	f"</notes>\n<segment>\n<source>{xmlEscape(source)}</source>\n</segment>\n</unit>\n",
)

I cannot find a way to disable this behaviour - or disabling string concatenation in general when using ruff format.
Any suggestions on how to use ruff format without multiline string concatenation would be helpful.

Reasoning

Multi-line strings split over new lines is usually a very intended form of syntax.
Splitting strings over multiple lines at fixed positions helps with readability.
I think there is more value in disabling this feature for ruff format than having it enabled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    formatterRelated to the formatterstyleHow should formatted code look

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions