没有键入模块的 Python 类型别名 TypeError: 'type' object is not subscriptable

时间:2021-03-13 21:45:17

标签: python python-3.5

我之前使用过 from typing import Dict, List 等,但看到 https://docs.python.org/3/library/typing.html 给出示例类型别名

<块引用>
ConnectionOptions = dict[str, str]
Address = tuple[str, int]
Server = tuple[Address, ConnectionOptions]

当我尝试使用自己的代码时

MyType = list[tuple[int, list[int]]]

我得到了

<块引用>

TypeError: 'type' 对象不可下标

是否仍然无法使用小写类型名称作为类型提示?如果是,我怎样才能成功?

0 个答案:

没有答案