Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dataclasses slots causes super() to raise TypeError #93593

Closed
Bluenix2 opened this issue Jun 7, 2022 · 2 comments
Closed

Dataclasses slots causes super() to raise TypeError #93593

Bluenix2 opened this issue Jun 7, 2022 · 2 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@Bluenix2
Copy link
Contributor

Bluenix2 commented Jun 7, 2022

Summary

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)
... class Base:
...     def __eq__(self, other: object) -> bool:
...         raise RuntimeError
...
>>>
>>> @dataclass(slots=True)
... class Subclass(Base):
...     def __eq__(self, other: object) -> bool:
...         return super().__eq__(other) and False
...
>>> 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.


@ericvsmith

@Bluenix2 Bluenix2 added the type-bug An unexpected behavior, bug, or error label Jun 7, 2022
@JelleZijlstra
Copy link
Member

Related: #90562

@Bluenix2
Copy link
Contributor Author

Bluenix2 commented Jun 7, 2022

Yes this appears to be a duplicate

@Bluenix2 Bluenix2 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants