Skip to content
Layout№ 20stack-method-chainsreflow-callsreflow-signaturesreflow-collectionsalign-colons

stack-adjacent-strings ​

stack-adjacent-strings breaks a of string literals to one literal per line once the joined line overflows code-line-length, so the seam between one literal and the next falls at a line end rather than wherever the author stopped typing. The width is measured from the the run sits at once align-equals the row that carries it.

A run already inside a bracket pair breaks in place, each later literal written at the indent of the row the run opens on, which is how a call argument, a collection element, and a dict value take the break. A run standing where no bracket encloses it, a return value or an assignment's right side among them, gains the parentheses the continuation needs, its literals one indent step in and the closing ) back at the statement's indent.

emit's call parentheses already enclose the two-literal , which overflows the code-line-length = 60 the case sets. The run breaks in place, one literal per line inside emit(...), with "and the trailing clause" written at the indent of the row the run opens on, because a run already inside a bracket pair takes no nested pair of its own.

prose.toml
toml
code-line-length = 60
emit(
    "the opening clause of this notice "
    "and the trailing clause"
)
python

The rule only ever breaks a run, so a run already written one literal per line keeps that layout whatever its width, backslash-continued and parenthesized alike. A run spanning several lines with two literals still sharing one is rewritten to one per line whatever the width, because the ragged seam is the defect rather than the line count.

A run keeps its line however wide in each of the following cases:

  1. A run standing as a body's leading expression, because parenthesizing it would leave a that no longer reads as one.
  2. A run with a triple-quoted part that spans lines, because moving that part would shift its opening line and change the interior the source pinned.
  3. A run with a comment anywhere inside the enclosing pair, the comment keeping the run in place.

Bytes runs and runs mixing an or t-string with a plain literal all break the same way, since each is one implicitly concatenated expression. The break falls between the parts and never inside one, so a replacement field keeps its own text as written. A run in a docstring slot and a line no break can bring within are both left for line-overflow to report.

Configuration ​

KeyTypeDefaultMeaning
enabledbooltrueTurns the rule on or off.

The Canonical Case ​

message's joins two adjacent string literals on one line that overflows code-line-length. The run is wrapped in parentheses and broken to one literal per line, so the seam between "the opening clause of this notice " and "and the trailing clause" falls at a line end.

prose.toml
toml
code-line-length = 60
message = (
    "the opening clause of this notice "
    "and the trailing clause"
)
python

More Examples ​

payload's two bytes literals concatenate the way adjacent str literals do, and together they overflow the line. The is wrapped in parentheses and broken to one literal per line, the same break an overflowing str run gets, because a bytes run is one expression.

prose.toml
toml
code-line-length = 60

table's single entry has a as its key rather than its value, and the entry overflows the line. The run breaks at the entry's own indent rather than hanging at the :, so the run breaks between its two literals at the entry's four-space indent, the first literal on the entry's opening row and the second followed by : 1 on the next.

prose.toml
toml
code-line-length = 60

table's single entry has a as its value, and the entry overflows the line. The run breaks at the indent of the entry's own row rather than at the the value opens on, so the entry keeps its key: value line whole instead of hanging at the :.

prose.toml
toml
code-line-length = 60

build's return value is a two-literal with no bracket of its own around it, and it overflows the line. The run is wrapped in parentheses and broken to one literal per line, with the closing ) written back at the statement's indent.

prose.toml
toml
code-line-length = 60

helper(alpha) opens and closes before the in emit(helper(alpha), ...), so the bracket enclosing the run is emit's own parentheses rather than the nested helper(...) pair that already closed. The run breaks in place, the second literal dropping to the argument row's indent, leaving helper(alpha) and the first literal together on the row where they started.

prose.toml
toml
code-line-length = 60

The subscript in value = registry[...] never expands onto lines of its own, so the inside it would otherwise break onto the statement's own row. The run is wrapped in its own parentheses rather than broken in place, because a continuation at the statement's indent would read as the next statement.

prose.toml
toml
code-line-length = 60

label's mixes an , f"the opening clause {value} of this notice ", with the plain literal "and the trailer", and together they overflow the line. The run breaks between the two parts and leaves the {value} replacement field untouched inside its f-string, because the break falls between parts and never inside one.

prose.toml
toml
code-line-length = 60

message's spans two lines, with "the opening clause " and "and a middle clause" sharing the first line and a third literal on its own. The whole run is rewritten to one literal per line, because the ragged seam is the defect the rule removes, whatever the line count.

prose.toml
toml
code-line-length = 60

label's two t"..." template-string literals, parsed under the target-version = "3.14" the case sets, concatenate the way str and bytes literals do, and together they overflow the line. The is wrapped in parentheses and broken to one literal per line, the same break any other over-budget run gets.

prose.toml
toml
code-line-length = 60
target-version = "3.14"

message's is already written one literal per line, continued across the line break with a trailing backslash rather than parentheses. The stays exactly as written, because the rule keeps any run already at one literal per line, backslash-continued and parenthesized alike.

prose.toml
toml
code-line-length = 60

The # keep the seam here comment sits inside the parentheses enclosing message's . The run stays at its source layout, because rewriting the pair would move the comment onto a different line from the one its author put it on.

prose.toml
toml
code-line-length = 60

message's is already written one literal per line, "a short clause " then "and another", even though the joined form would fit code-line-length. The run keeps its layout rather than rejoining, because the rule only ever breaks a run and never rejoins one.

prose.toml
toml
code-line-length = 60

message's has a triple-quoted part already spanning two lines beside the plain literal "and the trailing clause". The run is left exactly as written, because moving the triple-quoted part would shift its opening line and change the interior the source pinned.

prose.toml
toml
code-line-length = 60

The two adjacent string literals in handler's body sit in the slot, as the function's first statement. The is kept on one line however wide it runs, because wrapping it in parentheses would leave a value that no longer reads as a docstring, and the over-budget line is left for line-overflow to report.

prose.toml
toml
code-line-length = 60

message's joins two literals on one line that fits code-line-length, "a short clause " "and another". The run is left on one line, because the break reads the rather than the mere presence of a concatenation.

prose.toml
toml
code-line-length = 60
Layout

reflow-calls

Explodes a call to one argument per line once its argument count passes max-args, its width passes code-line-length, or an argument spans rows, and rejoins a list broken anywhere else onto one row.

Layout

reflow-collections

Expands a list, tuple, dict, or set literal across lines once it overflows code-line-length or a dict passes max-dict-entries, and rejoins a construct broken anywhere but an entry boundary.

Lint

line-overflow

Reports a line still over its line budget once no layout rule can shorten it.

Layout

reflow-parentheses

Removes a grouping parenthesis pair that changes nothing, and breaks one whose joined form overflows code-line-length into a row per operand, adding the pair around an over-budget test, returned value, or assigned value.

Layout

reflow-signatures

Writes a function signature either on one line or one parameter per line, expanding it once it overflows code-line-length, passes max-params, or carries a parameter spanning rows.

0.11.0Versione83e7e6Commit43Rules1830Fixtures2026-11-19Updated