Skip to content

Commit

Permalink
Fix radd Any
Browse files Browse the repository at this point in the history
  • Loading branch information
erezsh committed Feb 29, 2024
1 parent 7de3405 commit 78cbd83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions runtype/base_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Type(ABC):
"""Abstract Type class. All types inherit from it.
"""
def __add__(self, other: _Type):
if isinstance(other, AnyType):
return other
return SumType.create((self, other))

def __mul__(self, other: _Type):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ def test_pytypes2(self):
self.assertRaises(ValueError, type_caster.to_canon, typing.Tuple[int, str, ...])


def test_pytypes3(self):
assert Any + Int == Any
assert Int + Any == Any


def test_canonize_pytypes(self):
pytypes = [
Expand Down

0 comments on commit 78cbd83

Please sign in to comment.