dataclasses_inheritance
error
Dataclass field without a default after a field with a default
A dataclass synthesizes an __init__ whose parameters follow field declaration order. A field without a default that follows a field with a default would produce a non-default argument after a default one — a TypeError at class-definition time. field(default=...) and InitVar fields with a value both count as "has a default"; ClassVar, kw_only, and field(init=False) fields are excluded because they do not become positional __init__ parameters.
@dataclass
class C:
a: int = 0
b: int # E0157: no-default field after a defaulted one
How to handle it
Every rule is on by default — strict is the default, not a cage. You can dial
dataclasses_inheritance down per-file or per-path from your editor or
pyproject.toml, or fix the code
so it type-checks. See the Type System rules and
the complete diagnostic reference.
Canonical URL: https://www.basilisk-python.dev/errors/dataclasses_inheritance