from typing import Tuple
def test_1(inp1: Tuple[int, int, int]) -> None:
pass
def test_2(inp2: Tuple[int, int, int]) -> None:
test_tuple = tuple(e for e in inp2)
reveal_type(test_tuple)
test_1(test_tuple)
在上面的代码上运行mypy
时,我得到:
error: Argument 1 to "test_1" has incompatible type "Tuple[int, ...]"; expected "Tuple[int, int, int]"
是test_tuple
不是保证有3个int
元素?不mypy
处理这样的列表推导,还是有另一种在这里定义类型的方法?