Skip to content

Auto-Fix Rules

An auto-fix rule rewrites source under prose format and reports each rewrite as a Severity::Format diagnostic under prose check. Each rule settles one layout question Prose can answer mechanically (an alignment column, an alphabetical order, a blank-line count, a collection layout, a trailing comma) and emits an Edit list the Pipeline applies between rules. An auto-fix rule never reports a change the binary will not itself write.

align-colons

Alignment

Pads the space before : so consecutive dict entries, annotated assignments, signature annotations, and docstring entries share one column, with a docstring entry's parenthesized type in a column of its own.

align-comments

Alignment

Pads the gap before each trailing comment in a run so every # sits at one shared column.

align-comparisons

Alignment

Pads the space before each comparison operator in a multi-line and or or chain so the operators share one column.

align-equals

Alignment

Pads the space before = so consecutive assignments, annotated parameter defaults, and an exploded call's keyword arguments share one column.

align-imports

Alignment

Pads the space before the import keyword across consecutive from imports, or before as across consecutive aliased imports, so the keywords share one column.

align-match-case

Alignment

Folds each single-statement case arm onto one line and pads the space before its : so consecutive arms share one column.

alphabetize-siblings

Ordering

Sorts sibling entries whose order carries no meaning, covering import names, dict keys, class-body members, keyword arguments, and docstring entries.

band-constants

Ordering

Moves module-level constants into a leading band below the imports and a trailing band below the definitions, and sorts each band.

expand-docstrings

Docs

Expands a single-line triple-quoted docstring so its opener, its body, and its closer each sit on a line of their own.

frame-docstrings

Docs

Rewrites a docstring's quotes to the triple-double-quote form and puts a multi-line docstring's opener and closer on their own lines.

group-imports

Ordering

Moves each import in a run into its section, __future__ first, then bare, then external from, then local-package.

modernize-annotations

Formatting

Rewrites Optional[T], Union[X, Y], and the typing generics to the T | None, X | Y, and builtin forms the target runtime supports.

normalize-comment-spacing

Formatting

Puts one space after a comment's hash run and at least two spaces between code and a trailing comment.

normalize-comparisons

Formatting

Rewrites a comparison to state its check directly, using is against None, putting the variable side first, and folding a leading not into its operator.

normalize-literals

Formatting

Rewrites every string and numeric literal to one spelling of quote character, string prefix, and numeric case.

prefer-fstring

Formatting

Converts printf-style % interpolation and str.format() calls to f-strings wherever both forms render the same text.

prune-inert-imports

Formatting

Removes an import that binds a name nothing references or repeats a binding an earlier import already made, and reports the unreferenced one in a package __init__.py instead of removing it.

reflow-calls

Layout

Explodes a call to one keyword 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.

reflow-collections

Layout

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.

reflow-imports

Layout

Splits a from … import … that overflows import-line-length into repeated-prefix statements, breaks a comma-joined import a, b into one statement per module, and merges repeated from statements of one module into one line.

reflow-parentheses

Layout

Removes a grouping parenthesis pair that changes nothing, and breaks one whose joined form overflows code-line-length into a row per operand.

reflow-signatures

Layout

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.

shed-backslash-continuations

Formatting

Removes a trailing backslash and rejoins its statement, adding parentheses where the joined line would overflow the budget.

shed-redundant-base

Formatting

Removes an explicit object base and the empty parentheses on a class header with no bases.

shed-super-args

Formatting

Removes the class and instance arguments from a super(C, self) call, leaving the bare super() the interpreter resolves on its own.

simplify-comprehensions

Formatting

Removes a collection constructor wrapped around a literal, comprehension, or generator that already builds that collection, and replaces a comprehension that copies its input unchanged with the constructor call.

space-statements

Formatting

Sets the blank-line count between module-level definitions, class members, import groups, and the __main__ guard to PEP 8's canonical values.

stack-adjacent-strings

Layout

Breaks a run of implicitly concatenated string literals to one literal per line once the joined line overflows code-line-length.

stack-method-chains

Layout

Breaks a method chain to one link per line once it overflows code-line-length or carries more links than max-links, hanging each link beneath the head's dot.

strip-none-return

Formatting

Removes a bare -> None return annotation, since an omitted one already reads as returning nothing.

strip-stranded-padding

Alignment

Removes padding that lines up with nothing, before the : of a one-member group and just inside a bracket, and settles the gap after a : to one space.

strip-trailing-commas

Formatting

Removes the trailing comma from a collection, signature, call, class base list, or type-parameter list, leaving tuples alone.

wrap-docstrings

Docs

Wraps a docstring's description prose to docstring-line-length and its Title-case-headed sections to the budget docstring-structured-policy selects.

The Pipeline Order reference lists the fixed order these rules run in, the Configuration reference lists the per-rule facets, and the Lint landing covers the rules that report a diagnostic without rewriting.