> @dataclass > class Foo: > x: dict = field(default_factory=dict) > @dataclass > class Bar(Foo): > y: int = 1 > @dataclass > class Baz(Foo): > def blorf(self): > print('hello') > Foo().x {} > Bar().x {} > Baz().x Traceback (most recent call last): File "", line 1, in TypeError: __init__() missing 1 required positional argument: 'x' --- I understand that this is desired behavior when the subclass contains non-default attributes. But subclasses that define no additional attributes should work just the same as those that define only additional default attributes. A similar issue was raised and dismissed when dataclasses was in development on GitHub: https://github.com/ericvsmith/dataclasses/issues/112, but that only concerned the case of subclasses defining non-default attributes.
That's a great bug report. Thanks for the tiny code to replicate it. It turns out the code isn't quite doing what I thought. I'll have to give some thought to exactly how I'm going to handle this without breaking other cases, but I should have it fixed soon. Thanks again.