小编mpa*_*kov的帖子

连接元组的 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)

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

python mypy

4
推荐指数
1
解决办法
1342
查看次数

标签 统计

mypy ×1

python ×1