Skip to content

Commit

Permalink
Merge pull request #46 from erezsh/dev
Browse files Browse the repository at this point in the history
types: fix for tuple <= sequence
  • Loading branch information
erezsh authored Nov 14, 2023
2 parents 6ec7b0e + 85834ec commit 5bea984
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion runtype/base_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def __eq__(self, other):


def __le__(self, other):
if isinstance(other, type(self)):
if isinstance(other, GenericType):
return self.base <= other.base and self.item <= other.item

elif isinstance(other, DataType):
Expand Down
3 changes: 3 additions & 0 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ def test_tuple_ellipsis(self):
assert_isa((1,2,3), Tuple[int, ...])
self.assertRaises(TypeError, assert_isa, (1, "2"), Tuple[int, ...])

assert issubclass(Tuple[str, ...], typing.Sequence[str])
assert not issubclass(Tuple[str, ...], typing.Sequence[int])

@unittest.skipIf(sys.version_info < (3, 8), "Not supported before Python 3.8")
def test_py38(self):
assert isa('a', typing.Literal['a', 'b'])
Expand Down

0 comments on commit 5bea984

Please sign in to comment.