如何解决pydocstyle错误“D205:摘要行和描述之间需要1个空行(发现0)”?

Ric*_*kon 12 python docstring

我正在尝试使用 pydocstyle 检查我的文档字符串的质量,但出现此错误:

D205: 1 blank line required between summary line and description (found 0)

这是我的代码的样子

def func(input):
    """

    Function that does something interesting.
        Args:
            -input- Input of the function

    Returns:
        output- Output of the function

    """
    data = words + sentences
    corpus= somefunction(data)
Run Code Online (Sandbox Code Playgroud)

当我在文档字符串和函数语句之间添加一个空行时;

def func(input):
    """

    Function that does something interesting.
        Args:
            -input- Input of the function

    Returns:
        output- Output of the function

    """

    data = words + sentences
    corpus= somefunction(data)
Run Code Online (Sandbox Code Playgroud)

我得到这个错误:

D202: No blank lines allowed after function docstring (found 1)

我该如何解决?谢谢你的帮助。

ack*_*ack 12

请参阅PEP 257 -- 文档字符串约定

def func(input):
    """**summary line** Function to do something interesting.

    **description starts after blank line above**
    Args:
        -input- Input of the function

    Returns:
        output- Output of the function

    """
    # no blank line allowed here

    data = [words, sentences]
    corpus = somefunction(data)
Run Code Online (Sandbox Code Playgroud)

  • @Lutaaya 摘要行应该是“一行”,后跟一个“空白”行。 (2认同)