跳到内容

缺少摘要行后的空行 (D205)

源自 pydocstyle 代码检查器。

有时提供修复。

作用

检查文档字符串摘要行是否未用一个空行与文档字符串描述分隔开。

为什么这不好?

PEP 257 建议多行文档字符串应包含“像单行文档字符串一样的摘要行,后跟一个空行,再后跟更详细的描述”。

示例

def sort_list(l: list[int]) -> list[int]:
    """Return a sorted copy of the list.
    Sort the list in ascending order and return a copy of the
    result using the bubble sort algorithm.
    """

建议改为

def sort_list(l: list[int]) -> list[int]:
    """Return a sorted copy of the list.

    Sort the list in ascending order and return a copy of the
    result using the bubble sort algorithm.
    """

参考