在函数签名中使用类型提示时,如果我要遵守 numpydoc 风格,是否也需要在文档字符串中指定参数类型?
def add(a: float, b: int) -> float:
"""
Parameters
----------
a
Fist number.
b : int
Second number.
Returns
-------
float
Result of a + b
"""
return a + b
参数部分中
a
的定义是否足够?
目前我认为答案是否,如果你想直接使用
numpydoc
。有一张开放票:https://github.com/numpy/numpydoc/issues/196
我希望任何更改都将在
numpydoc
文档中。
但是:如果您希望使用
docstrings
包以类似
numpydoc
的风格渲染
numpydoc
,那么您可能有选择。
这是我发现的(部分是通过那个numpydoc
问题):