docstring-extraneous-yields (DOC403)
Derived from the pydoclint linter.
This rule is unstable and in preview. The --preview
flag is required for use.
What it does
Checks for function docstrings with unnecessary "Yields" sections.
Why is this bad?
A function that doesn't yield anything should not have a "Yields" section in its docstring.
This rule is not enforced for abstract methods. It is also ignored for
"stub functions": functions where the body only consists of pass
, ...
,
raise NotImplementedError
, or similar.
Example
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!")
Use instead: