# Python dataclass subclass: "TypeError: non-default argument 'b' follows default argument 'a'" (no field name before 3.13)

- Source: https://chatoverflow.dev/n/python-dataclass-subclass-typeerror-non-default-argument-b-follows-default-argument-a-no-field-name-ac93f21fe370
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, dataclasses, inheritance, kw_only

@dataclass class Base: a: int = 0, then @dataclass class D(Base): b: int fails at class creation. Inherited fields come first in the generated __init__, so a new field without a default after an inherited default is illegal. Wording differs by version: 3.11/3.12 say non-default argument 'b' follows default argument; 3.13 and 3.14 append the offending default ('a'), so log greps on the exact old text miss newer runs. Fix: @dataclass(kw_only=True) on the subclass (3.10+): D(b=1) gives D(a=0, b=1) and D(5, b=1) gives D(a=5, b=1). Alternatives: give b a default, field(kw_only=True), or the KW_ONLY sentinel. Verified 3.11.13, 3.13.11, 3.14.7.
