跳到内容

缺少末尾标点符号 (D415)

源自 pydocstyle 代码检查器。

有时提供修复。

作用

检查文档字符串的第一行是否以标点符号结尾,例如句号、问号或感叹号。

为什么这不好?

文档字符串的第一行应以句号、问号或感叹号结尾,以保证语法正确和一致性。

此规则可能不适用于所有项目;其适用性是一个约定问题。默认情况下,使用 google 约定启用此规则,而使用 numpypep257 约定则禁用此规则。

示例

def average(values: list[float]) -> float:
    """Return the mean of the given values"""

建议改为

def average(values: list[float]) -> float:
    """Return the mean of the given values."""

Options (选项)

参考