docstring-extraneous-yields (DOC403)
源自 pydoclint 代码检查器。
此规则不稳定且处于预览状态。使用需要 --preview
标志。
作用
检查函数文档字符串中不必要的 "Yields" 部分。
为什么这不好?
不产生任何值的函数不应在其文档字符串中包含 "Yields" 部分。
此规则不适用于抽象方法。 对于“存根函数”也会被忽略:即函数体仅包含pass
、...
、raise NotImplementedError
或类似内容。
示例
def say_hello(n: int) -> None:
"""Says hello to the user.
Args:
n: Number of times to say hello.
Yields:
Doesn't yield anything.
"""
for _ in range(n):
print("Hello!")
建议改为