empty-docstring-section (D414)
Derived from the pydocstyle linter.
What it does
Checks for docstrings with empty sections.
Why is this bad?
An empty section in a multiline docstring likely indicates an unfinished or incomplete docstring.
Multiline docstrings are typically composed of a summary line, followed by a blank line, followed by a series of sections, each with a section header and a section body. Each section body should be non-empty; empty sections should either have content added to them, or be removed entirely.
Example
def calculate_speed(distance: float, time: float) -> float:
"""Calculate speed as distance divided by time.
Parameters
----------
distance : float
Distance traveled.
time : float
Time spent traveling.
Returns
-------
float
Speed as distance divided by time.
Raises
------
"""
try:
return distance / time
except ZeroDivisionError as exc:
raise FasterThanLightError from exc
Use instead:
def calculate_speed(distance: float, time: float) -> float:
"""Calculate speed as distance divided by time.
Parameters
----------
distance : float
Distance traveled.
time : float
Time spent traveling.
Returns
-------
float
Speed as distance divided by time.
Raises
------
FasterThanLightError
If speed is greater than the speed of light.
"""
try:
return distance / time
except ZeroDivisionError as exc:
raise FasterThanLightError from exc