missing-returns¶
Part of: Enrichment Check
| Check | enrichment |
| Category | required |
| Applies to | functions, methods |
| Since | v1.13.0 |
Function returns a value but has no Returns section
What it detects¶
This rule flags functions and methods that contain return <expr> statements in their body but have no Returns: section in their docstring. Bare return and return None are treated as control-flow idioms and do not trigger this rule.
Why is this a problem?¶
Callers of the function don't know what to expect back. Without a documented Returns: section, downstream code can't correctly handle the return value, and API documentation generated by mkdocstrings will lack return type information.
How to Fix¶
Add a Returns: section describing the type and meaning of the return value:
For functions with multiple return types, describe each possibility:
Example¶
Exceptions¶
This rule is automatically skipped for:
- Dunder methods (
__init__,__repr__,__len__, etc.) @propertyand@cached_propertymethods@abstractmethodmethods (interface contracts)@overloadsignatures- Stub functions (body is
pass,..., orraise NotImplementedError)