我正在编写一个返回元组并使用类型注释的函数。为此,我写了:
def foo(bar) -> Tuple[int, int]:
pass
Run Code Online (Sandbox Code Playgroud)
这会运行,但我收到一条警告:
“元组”未定义 Pylance 报告UndefinedVariable
鉴于我正在编写许多返回元组类型的函数,我想摆脱警告。我假设我只需要导入Tuple
引用的包,但是正确的 Python 包是什么?
根据我的研究,我倾向于认为这是软件包typing
,但我不确定。