缩进不足 (D207)
源自 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.
"""
格式化器兼容性
我们不建议将此规则与 格式化程序 一起使用。格式化程序强制执行一致的缩进,使该规则变得多余。