| name | column-aligned-fields |
| description | Enforce column-aligned inline comments on dataclass and enum fields. Use when writing or reviewing Python dataclasses, enums, TypedDicts, or any structured type with inline field comments. |
Column-Aligned Field Comments
When a dataclass, enum, or similar structured type has inline comments on its fields, align
all comments to the same column and wrap the block with # fmt: off / # fmt: on so the
formatter preserves the alignment.
Rules
- The comment column starts two spaces after the longest value expression in the group.
- Every inline comment is a complete sentence ending with a period.
- Fields without comments leave the comment column empty (no filler).
# fmt: off goes on the line immediately before the decorator or class statement.
# fmt: on goes on the line immediately after the last field.
Example
@dataclass
class RawFieldSpec:
"""A single field extracted from a provider's OpenAPI schema."""
provider: str
name: str
type_str: str
required: bool
description: str | None = None
constraints: JSONObject = dataclass_field(default_factory=dict)
union: UnionInfo | None = None
items: ArrayItemsInfo | None = None
additional_properties: JSONObject | bool | None = None
variant_metadata: list[VariantMeta] | None = None
class TransferCode(IntEnum):
"""Transfer type codes for billing.transfers.code column."""
USAGE = 1
BALANCE_DEPOSIT = 100
CREDIT_ADJUSTMENT = 101
CREDIT_GRANT = 102
API_USAGE = 200
MCP_BUYER_CHARGE = 400
MCP_SELLER_HOLD = 410
MCP_SELLER_CLAWBACK = 411
When NOT to Use
- Classes with fewer than 3 fields (alignment adds no value).
- Fields whose comments would all be trivially obvious from the name.
- Non-structured code (regular variables, function locals).