python 打字:具有多个返回值的 mypy 警告

问题描述 投票:0回答:0

使用 python 3.8 和 mypy 1.4.1,我收到 mypy 警告

Expected type 'Dict[str, float]', got 'Dict[str, Tuple[float, float, float]]' instead

当使用多个返回值(作为元组)并将其中一个添加到字典中时。

from typing import Dict, Tuple

def foo() -> Tuple[float, float, float]:
    return 1, 3, 5

a: Dict[str, float] = {}
a["asdf"], _, _ = foo()

针对

a
发出警告。

python-3.x mypy typing
© www.soinside.com 2019 - 2024. All rights reserved.