跳到内容

docstring-tab-indentation (D206)

源自 pydocstyle 代码检查器。

作用

检查使用制表符缩进的文档字符串。

为什么这不好?

PEP 8 建议使用空格代替制表符进行缩进。

示例

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

格式化器兼容性

我们不建议将此规则与 格式化器 一起使用。格式化器会强制执行一致的缩进,从而使该规则变得多余。

当使用 format.indent-style="tab" 时,该规则也与 格式化器 不兼容。

参考