-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
Description
Bug Report
mypy doesn't infer __eq__ and __hash__ implementations for dataclasses.
To Reproduce
from abc import ABC, abstractmethod
from dataclasses import dataclass
class FType(ABC):
@abstractmethod
def __eq__(self, other): ...
@abstractmethod
def __hash__(self): ...
@dataclass(eq=True, frozen=True)
class ConcreteType(FType):
a: int
b: str
if __name__ == "__main__":
ct = ConcreteType(1, "b")
print(ct.__eq__)Expected Behavior
It should pass.
Actual Behavior
mypy_playground.py:21: error: Cannot instantiate abstract class "ConcreteType" with abstract attributes "__eq__" and "__hash__" [abstract]
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.17.1
Reactions are currently unavailable