使用 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
发出警告。