Support for typing.Tuple[type, ...]

This commit is contained in:
Claude
2016-01-17 12:43:23 +01:00
parent a5fc149f9d
commit ae701b2f9a
2 changed files with 7 additions and 2 deletions

View File

@@ -35,6 +35,11 @@ def factory(typing_name, indextypes):
class Tuple(Sequence, tuple):
def __getitem__(self, index):
if indextypes[1] == ...:
# https://www.python.org/dev/peps/pep-0484/#the-typing-module
# Tuple[int, ...] means a tuple of ints of indetermined length
return indextypes[0]()
else:
return indextypes[index]()
class AbstractSet(Iterable, abc.Set):

View File

@@ -83,7 +83,7 @@ def tuple(
q[2]
#? B()
r[0]
##? B() --- TODO fix support for arbitrary length
#? B()
r[1]
#? B()
r[2]