You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Attempting to use super() with a dataclass which has slots=True specified raises a TypeError: super(type, obj): obj must be an instance or subtype of type.
Reproducible example
>>> from dataclasses import dataclass
>>>
>>>
>>> @dataclass(slots=True)
... classBase:
... def__eq__(self, other: object) -> bool:
... raiseRuntimeError
...
>>>
>>> @dataclass(slots=True)
... classSubclass(Base):
... def__eq__(self, other: object) -> bool:
... returnsuper().__eq__(other) andFalse
...
>>> Subclass() == Subclass()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 4, in __eq__
TypeError: super(type, obj): obj must be an instance or subtype of type
Environemnt
This is run on CPython 3.10 with a file containing the current code found under Lib/dataclasses.py as of opening this issue.
Summary
Attempting to use
super()
with a dataclass which hasslots=True
specified raises aTypeError: super(type, obj): obj must be an instance or subtype of type
.Reproducible example
Environemnt
This is run on CPython 3.10 with a file containing the current code found under
Lib/dataclasses.py
as of opening this issue.@ericvsmith
The text was updated successfully, but these errors were encountered: