我有一个接受特定元组并连接的函数,我试图指定输出的类型,但 mypy 不同意我的观点。
文件test.py:
from typing import Tuple
def test(a: Tuple[str, str], b: Tuple[int, int]) -> Tuple[str, str, int, int]:
return a + b
Run Code Online (Sandbox Code Playgroud)
运行 mypy 0.641,mypy --ignore-missing-imports test.py我得到:
test.py:5: error: Incompatible return value type (got "Tuple[Any, ...]", expected "Tuple[str, str, int, int]")
Run Code Online (Sandbox Code Playgroud)
我想这是正确的,但更通用,因为我指定了我的输入。