Open
Description
While working on #11463 I found that adding __hash__: None
annotations does not work correctly.
Mypy says:
from dataclasses import dataclass
@dataclass(unsafe_hash=False, eq=True, frozen=False)
class SecondCase2:
x: int
__hash__: None # E: Incompatible types in assignment (expression has type "None", base class "object" defined the type as "Callable[[object], int]")
print(SecondCase2(1).__hash__) # N: Revealed type is "None" \
# E: Missing positional argument "__hash__" in call to "SecondCase2"
It looks like __hash__
is added to fields
and __init__
. While runtime version works just fine:
» python out/ex.py
SecondCase2(x=1, __hash__=<slot wrapper '__hash__' of 'object' objects>)
I will fix it in the same PR as #11463