numpydoc:当我使用类型提示时,我可以省略文档字符串中的类型声明吗?

问题描述 投票:0回答:1

在函数签名中使用类型提示时,如果我要遵守 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
的定义是否足够?

type-hinting pep8 docstring numpydoc
1个回答
0
投票

目前我认为答案是如果你想直接使用

numpydoc
。有一张开放票:https://github.com/numpy/numpydoc/issues/196

我希望任何更改都将在

numpydoc
文档中。

但是:如果您希望使用

docstrings
以类似numpydoc的风格
渲染
numpydoc,那么您可能有选择。

这是我发现的(部分是通过那个

numpydoc

问题):

© www.soinside.com 2019 - 2024. All rights reserved.