-
- Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly
Description
problem
class A: def __eq__(self, o: object, /) -> bool: return self is o reveal_type(A().__hash__) # def () -> builtins.int
yet
>>> class A: ... def __eq__(self, o: object, /) -> bool: ... return self is o ... >>> type(A.__hash__) <class 'NoneType'>
solution
iff. class A
, and only class A
(i.e. excluding any base classes)
- implements
__eq__
, and - does not implement
__hash__
infer A.__hash__: ClassVar[None]
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly