Skip to content

Alignment Rules โ€‹

The alignment rules align a shared token across consecutive rows so columns of assignments, annotations, and patterns read as vertical groups. The shared math lives in the Aligner primitive, and each rule supplies the walker that decides what counts as a group. The per-rule max-shift knob caps how far rows shift to align, with max-shift-policy (split / drop) deciding how a group whose widest member exceeds the cap resolves. A # prose: skip on one row holds it out of its group while the rest align around it.

align-colons

Alignment

Prose aligns the : separator across dict literals, dataclass and Pydantic fields, function-signature annotations, and docstring Args: blocks.

align-comparisons

Alignment

Prose aligns comparison operators vertically across the operands of a multi-line and-chain or or-chain.

align-equals

Alignment

Prose aligns the = separator across consecutive single-target assignments and annotated function-parameter defaults.

align-imports

Alignment

Prose aligns the import and as keywords across consecutive import statements.

align-match-case

Alignment

Prose aligns the post-pattern : across single-expression case bodies inside a match statement.

For the per-rule knobs, see the Configuration reference. For the math the rules share, see the Aligner primitive. The ColonTargets walker drives the five : contexts the alignment rules read against.