We can annotate variable-length homogeneous tuples using the ...
literal (aka Ellipsis
) like this:
def process_tuple(t: Tuple[str, ...]):
...
or for Python3.9+
def process_tuple(t: tuple[str, ...]):
...
After that, the errors should go away.
From the docs:
To specify a variable-length tuple of homogeneous type, use literal
ellipsis, e.g.Tuple[int, ...]
. A plainTuple
is equivalent to
Tuple[Any, ...]
, and in turn totuple
.