Running ruff check --select DOC201 --preview --isolated on
def foo(obj: object) -> None:
"""A very helpful description."""
if obj is None:
return None
print(obj)
reports a docstring-missing-returns (DOC201) diagnostic. Making the None return implicit means the diagnostic is raised no longer.
def foo(obj: object) -> None:
"""A very helpful description."""
if obj is None:
return
print(obj)
The expected behaviour is that the diagnostic is raised in neither situation, as the function returns None on all paths and the explicit return operates as an early exit.
I don't like the explicit None return and unnecessary-return-none (RET501) would catch this, but it still seems like the incorrect behaviour for this specific rule.
Reproduced on Ruff version 0.6.1.
Search terms: DOC201, docstring-missing-returns