Skip to content

Commit 4c177b0

Browse files
authored
Merge pull request #66 from erezsh/dev4
Fix eq/hash for copies of Python types
2 parents 7ff7204 + 5cf3a25 commit 4c177b0

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

runtype/base_types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def __mul__(self, other: _Type):
5252
def __le__(self, other):
5353
return NotImplemented
5454

55+
5556
class AnyType(Type):
5657
"""Represents the Any type.
5758

runtype/pytypes.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,15 @@ def cast_from(self, obj):
177177

178178
return obj
179179

180+
def __eq__(self, other):
181+
if type(other) != type(self):
182+
return False
183+
return self.kernel == other.kernel
184+
185+
def __hash__(self):
186+
return hash((type(self), self.kernel))
187+
188+
180189
class TupleType(PythonType):
181190
def test_instance(self, obj, sampler=None):
182191
return isinstance(obj, tuple)

0 commit comments

Comments
 (0)