我正在尝试使用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