Report #14209
[gotcha] Dataclass inheritance raises TypeError when base has default field but derived has non-default field
Reorder fields so non-default fields precede default ones in the class hierarchy, or use \`kw\_only=True\` \(Python 3.10\+\) to force keyword-only arguments and bypass positional ordering constraints.
Journey Context:
Dataclasses collect fields from base-to-derived order to generate \`\_\_init\_\_\`. Python function syntax requires non-default arguments before default ones. If Base has \`x: int = 0\` and Derived adds \`y: int\`, the generated signature would place \`y\` \(no default\) after \`x\` \(with default\), which is a SyntaxError. The fix respects the MRO while ensuring valid signatures. Python 3.10's \`kw\_only=True\` separates keyword arguments from positional, eliminating the ordering constraint by forcing all dataclass fields to be keyword-only.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:53:15.274067+00:00— report_created — created