I have a python function that looks as following:
from typing import Tuple
def test() -> Tuple[int]:
o: Tuple[int] = ()
for i in range(2):
o+=(i,)
return o
Evaluating this with mypy returns the errors
error: Incompatible types in assignment (expression has type "Tuple[]", variable has type "Tuple[int]")
error: Incompatible types in assignment (expression has type "Tuple[int, int]", variable has type "Tuple[int]")
Assigning the tuple and return value the type Tuple without the int specification resolves this problem. I would like to specify the contents of the tuple as well though. How can I achieve this?