跳到内容

三单引号 (D300)

源自 pydocstyle 代码检查器。

有时提供修复。

作用

检查文档字符串是否使用了 '''三单引号''' 而不是 """三双引号"""

为什么这不好?

PEP 257 建议使用 """三双引号""" 作为文档字符串,以确保一致性。

示例

def kos_root():
    '''Return the pathname of the KOS root directory.'''

建议改为

def kos_root():
    """Return the pathname of the KOS root directory."""

格式化器兼容性

我们建议不要将此规则与 formatter 一起使用。formatter 会强制使用一致的引号,从而使此规则变得多余。

参考