连接元组的 Mypy 类型

mpa*_*kov 4 python mypy

我有一个接受特定元组并连接的函数,我试图指定输出的类型,但 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)

我想这是正确的,但更通用,因为我指定了我的输入。

che*_*ner 6

一个已知问题,但似乎没有时间表可以mypy在 2019 年晚些时候修复以进行正确的类型推断。