align-colons
AlignmentProse aligns the : separator across dict literals, Args: blocks.
A function signature reads as either a one-line declaration or a stacked column of parameters. Mixed shapes (part on the def line, the rest indented underneath) force the reader to track two layout idioms at once.
code-line-length and max-inline-params.The rule expands a signature when its inline form overflows the configured code-line-length, or when its parameter count exceeds max-inline-params. Otherwise the signature collapses to a single line. A comment inside the parameter list pins the existing shape, because moving the parameters would orphan the comment from its anchor. The expanded form lays each parameter on its own line, indented one step past the def, with the closing ) flush left and the return annotation trailing on the same line.
| Key | Type | Default | Meaning |
|---|---|---|---|
enabled | bool | true | Toggle the rule on or off |
max-inline-params | positive int | false | 4 | Cap on the parameter count an inline signature can carry. Setting false disables the count trigger and leaves only the line-length budget |
The line-length budget comes from the top-level code-line-length key (default 88), which the rule reads directly. Setting max-inline-params to false makes the rule expand purely on line length, leaving inline-but-long signatures untouched when they fit the budget regardless of parameter count.
A five-parameter signature whose inline form fits the line budget pins the max-inline-params.
def render(
width: int,
height: int,
depth: int,
scale: int,
fast: bool,
):
return (width, height, depth, scale, fast)
A signature whose parameters overflow the line budget expands to one per line, while the parenthesized multi-line return
A three-parameter signature whose inline form overflows the default code-line-length of 88 columns expands, with the parameter count comfortably under the cap. The length trigger fires alone.
A two-parameter signature already in expanded shape, whose inline form fits under both thresholds, collapses back to a single line. The reverse direction of the rewrite is symmetric with expansion.
An outer async def and an inner sync def each trip the
A class method with self and four typed parameters trips the def position.
A @cache-decorated function with five parameters trips the (, leaving everything above the def keyword out of
A single typed parameter in expanded shape collapses to an inline signature once the inline form fits under both thresholds. The return ) on the same line, rather than landing on its own line.
Two signatures already at their canonical shape pass through unchanged. The inline two-parameter form fits both thresholds, and the expanded five-parameter form trips the
A comment anywhere between ( and ) pins the existing shape, overriding both count and length triggers. Each pinned signature keeps its comment in place rather than getting rewritten around, covering both own-line and trailing-line placements.
The parameters fit on one line, so they are left inline even though the return
Prose aligns the : separator across dict literals, Args: blocks.
Prose aligns the = separator across consecutive single-target assignments and annotated function-parameter defaults.
Prose 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.
Prose removes trailing commas from inside single-line collections.