我在PyCharm的文档片段中看到了这个。
def a_func()
Inferred type: () -> dict[str, dict]
我知道在函数定义中,
->
表示返回值,但是dict[str, dict]
部分是什么意思呢?
最简单的演示该语法的函数如下:
def a_func():
"""Docstring to suppress PEP8 warning."""
return {'a': {'b': 3}}
在编辑器→代码完成中的"自动弹出文档"设置中显示。启用此功能后,将鼠标悬停在this()
上方时,将显示上述片段。
dict[str, dict]
的例子。 - kiri