collection-layout
LayoutSplits list, tuple, dict, and set literals into one-entry-per-line layout once they overflow their width, or a dict crosses an entry-count cap.
A parenthesis pair wrapped around an expression only to span lines, or out of habit, is visual weight the expression does not carry meaning through.
joins a wrapped construct back onto the line it fits, yet it leaves the surrounding parentheses in place, because removing syntax belongs to no layout rule. closes that gap, dropping a grouping pair that binds nothing and reflowing the expression onto the line it now fits.The decision is structural rather than textual, so a pair sheds only where removing it leaves the parse unchanged. A precedence-bearing pair such as (a + b) * c stays because dropping it would rebind the multiplication, a generator and a walrus binding keep the parentheses the grammar requires of them, and the parentheses that form a one-element tuple stay part of the tuple rather than wrapping it. A pair whose interior carries a comment stays too, since folding the break would strand the comment off the line it describes.
A wrapped multi-line grouping folds onto one line when the bare form fits the budget and stays wrapped when it would overflow, so a short boolean condition reads as one clean line whereas a long one keeps its parentheses across the lines it needs. A pair nested inside another redundant pair sheds in the same pass, and each pair weighs its own fold against the text the pass's earlier sheds produce, so two sibling pairs on one statement answer the budget the joined line actually reaches rather than the width the source opened with.
| Key | Type | Default | Meaning |
|---|---|---|---|
enabled | bool | true | Toggles the rule on or off. |
A parenthesis pair that wraps an expression without binding anything sheds, so total = (base + tax) reflows to total = base + tax.
total = base + tax
label = name
A wrapped grouping whose single-line form fits the budget sheds and folds onto one line, so the condition reflows to ready = server.up and cache.warm.
Each pair is measured against the text the pass has already produced, so the second of two sibling groupings reads the column the first one's fold pushed it to and keeps its parentheses rather than compounding onto an over-budget line.
A redundant pair around a single-line return annotation sheds, so def total() -> (int): reflows to def total() -> int:.
The budget test narrows the interior by the two columns each nested pair sheds alongside the fold, so a grouping that only fits once its inner pairs are gone folds in the same pass rather than the one after.
A generator expression is illegal without its surrounding parentheses, so the pair stays.
The parentheses that form a tuple belong to the tuple rather than wrapping it, so a one-element tuple keeps them.
A grouping whose interior carries a comment keeps its parentheses, since folding the break would strand the comment off the line it describes.
A pair that binds tighter than the operator enclosing it stays, since dropping it would rebind the expression. Both (base + bonus) * factor and 2 ** (depth + 1) keep their parentheses.
An assignment expression keeps its pair whatever the surrounding context, leaving the binding readable as one rule rather than a positional exception.
A wrapped grouping whose folded form would overflow the budget keeps its parentheses across the lines it spans.
Splits list, tuple, dict, and set literals into one-entry-per-line layout once they overflow their width, or a dict crosses an entry-count cap.
Normalizes function signatures to one line or one parameter per line, gated by line length and inline-parameter count.
For per-statement opt-outs, the Suppression chapter covers the # prose: skip[shed-parentheses] directive, which holds every line a wrapped statement spans.