我正在尝试使用 numpy docstring 格式记录元组返回值,但无法使其与 pycharm 类型提示一起使用。
我尝试了多种方法,甚至找到了一种适用于该类型的方法,但不允许我为其每个元素添加描述。
要记录的函数示例:
def function():
foo = 42
bar = {
example : 1337,
dictionary : 46,
}
return foo, bar
现在,我可以记录它的一种方法是:
def function():
"""
This is the function summary.
Returns
-------
foobar : tuple[int,[dict[string, int]]
This is a description of the return type
"""
foo = 42
bar = {
'example' : 1337,
'dictionary' : 46,
}
return foo, bar
这会给我一个描述和正确的返回类型提示,但不是我想要的每个元素的单独描述。
这是我要实现的目标的非工作示例:
def function():
"""
This is the function summary.
Returns
-------
foo : int
This is an int
bar : [dict[string, int]
This is a dictionary
"""
foo = 42
bar = {
'example' : 1337,
'dictionary' : 46,
}
return foo, bar