跳到内容

函数定义前的空行 (D201)

源自 pydocstyle 代码检查器。

有时提供修复。

作用

检查函数文档字符串是否与函数定义之间存在一个或多个空行。

为什么这不好?

为了保持一致性,请删除函数定义与其文档字符串之间的任何空行。

示例

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

参考