types
types ¶
Violation
dataclass
¶
A single style violation, located by line so the runner can scope it to the edit.
Attributes:
| Name | Type | Description |
|---|---|---|
line |
int
|
1-based line number of the offending construct in the post-edit file. |
label |
str
|
Short human-readable description, rendered as |
StyleRule ¶
Bases: ABC
Base class for a single-tree AST style rule applied to Python edits and writes.
Subclass it and write the rule's message as the class docstring ({violations} is
substituted at fire time). Declare the rule as data by setting match to a
Matcher (and optionally label); override check
only for logic a matcher can't express. The class name is the rule's identity —
NoNestedImports becomes "no-nested-imports".
Example
StyleDiffRule ¶
Bases: StyleRule
Base class for a diff rule: flags constructs newly introduced by the change.
Like StyleRule, but it compares the pre-edit and
post-edit trees. The declarative form flags nodes matching match in the new tree
that were absent from the old tree (by unparsed source); override check when the
"newly introduced" identity needs custom logic.