I encounter a weird error while defining an immutable list type:
import sys
from re import split
from typing import Tuple, List, NewType
tokens = split("(\d+\.\d+)", sys.argv[1])
# this works perfectly
# Tokens = NewType("Tokens", List[str])
# print(Tokens(tokens))
# this doesn't work ...
Tokens = NewType("Tokens", Tuple[str])
print(Tokens(tuple(tokens)))
Here is the error that I get:
> mypy main.py
main.py:13: error: Argument 1 to "Tokens" has incompatible type "Tuple[Union[str, Any], ...]"; expected "Tuple[str]"
Found 1 error in 1 file (checked 1 source file)