align-imports
AlignmentProse aligns the import and as keywords across consecutive import statements.
Prose holds code to a line-length budget but leaves imports exempt by default, so a from a.deeply.nested.module import x, y, z, ... runs past the margin however wide its roster grows.
from ... import ... statements. Each statement repeats the module prefix and greedily packs as many alphabetized names as fit before the next line opens, so the imported names begin at the column the eye reaches after import on every line and a deep module path never drives them rightward.The rule acts on a single-line from ... import ... only. A from ... import *, a from-import already within budget, and a multi-line (parenthesized or backslash-continued) import stay untouched, and a lone name whose own line still overflows keeps its place rather than splitting further. Pair with
import keyword across the resulting run, which already carries one identical prefix per line.| Key | Type | Default | Meaning |
|---|---|---|---|
enabled | bool | true | Toggle the rule on or off |
The wrap budget comes from the top-level import-line-length key (default 120), governing the import wrap independently of code-line-length. An import is a roster
import-line-length to false drops the dedicated budget, so the import wrap falls back to code-line-length.A from ... import ... whose names overrun import-line-length splits into a run of repeated-prefix statements, each greedily packing the alphabetized names up to the budget before the next line opens.
from pkg.sub import alpha, beta, delta
from pkg.sub import epsilon, gamma
A relative import folds its leading dots into the repeated prefix, so every split line opens with the same from ..pkg import anchor.
An as-aliased name keeps its alias when the line splits, so each packed statement repeats the module prefix and holds every name as alias pair intact.
A from-import nested in a block splits with every continuation line carrying the block indent, and the budget counts the indent column so each packed line still fits.
A single name whose own from ... import ... line still overruns the budget stays in place rather than splitting further, since one name has nowhere left to break.
A from ... import * carries one name and passes through unchanged, even past the budget, because a star import has nothing to pack.
A from ... import ... that already fits the import budget keeps its single line, leaving the split for the genuinely long rosters.
Prose aligns the import and as keywords across consecutive import statements.
Prose alphabetizes import siblings, dict-key blocks, and
Prose surfaces a narrowly-used bare import that from x import … would replace.
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 normalizes function signatures to one line or one parameter per line, gated by line length and inline-parameter count.