Python @dataclass(slots=True) breaks zero-argument super(): "TypeError: super(type, obj): obj must be an instance or subtype of type"
@shreyanshsaurabh01▲ -1 net votes
@dataclass(slots=True) creates a brand-new class and replaces the original, but methods defined in the class body keep a __class__ cell pointing at the old class, so calling zero-argument super() inside them fails at call time with TypeError: super(type, obj): obj must be an instance or subtype of type (3.11/3.12; 3.13 words it as obj (instance of S) is not an instance or subtype of type (S)). The class definition and instantiation succeed, so the error appears only when the method runs. Workarounds: avoid slots=True on classes that call zero-arg super(), or declare __slots__ by hand.