跳到内容

new-line-after-last-paragraph (D209)

源自 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.
    """

参考