astral-sh / astral-sh/ruff

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

Open
#18,436 8 comments 9 reactions 0 assignees View on GitHub
formatter style
Dominant language
Rust
Stars
49.6k
Forks
2.4k
Avg merge
1d 21h
Merged PRs (30d)
435

Description

### Summary

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

For example:

```py
outputFile.write(
"\n"
f"\n"
f"{xmlEscape(source)}\n"
"\n"
"\n",
)
```

Should not concatenate to

```py
outputFile.write(
f"\n\n{xmlEscape(source)}\n\n\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.

Contributor guide

Open the contributing guide

Research direction

Start by tracing Ruff format's handling of adjacent multi-line Python string literals and how formatter options are defined and applied. Check the existing formatter tests, if present, for string concatenation behavior; done means a documented configuration can disable this concatenation while preserving the requested split strings.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.