Skip to content

unnecessary-multiline-docstring (D200)

Derived from the pydocstyle linter.

Fix is sometimes available.

What it does

Checks for single-line docstrings that are broken across multiple lines.

Why is this bad?

PEP 257 recommends that docstrings that can fit on one line should be formatted on a single line, for consistency and readability.

Example

def average(values: list[float]) -> float:
    """
    Return the mean of the given values.
    """

Use instead:

def average(values: list[float]) -> float:
    """Return the mean of the given values."""

Fix safety

The fix is marked as unsafe because it could affect tools that parse docstrings, documentation generators, or custom introspection utilities that rely on specific docstring formatting.

References