多行摘要第二行 (D213)
源自 pydocstyle 代码检查器。
修复总是可用的。
作用
检查文档字符串摘要行是否位于文档字符串的第二个物理行上。
为什么这不好?
PEP 257 建议多行文档字符串应包含“摘要行,就像单行文档字符串一样,后跟一个空行,然后是更详细的描述。”
摘要行应位于文档字符串的第二个物理行上,紧接在开头的引号和空行之后。
此规则可能不适用于所有项目;其适用性是一个约定问题。 默认情况下,使用 google
、numpy
和 pep257
约定时,此规则将被禁用。
有关替代方法,请参见 D212。
示例
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.
"""