Skip to content

Python · maintainability

redundant-class-docstring

python:redundant-class-docstring

Class docstrings must add information beyond the class name and bases.

Code
SARJ085
Default
error
Fix
none
Languages
python

Why

Restating a class declaration adds maintenance cost without helping a reader understand its contract.

Fix

Delete the redundant docstring or document an invariant, lifetime, exclusion, or other fact absent from the declaration.

Before / after

Executed by this rule’s unit tests.

Before

Docstring repeats the class name

app/policy.py · focus
class RetryPolicy:
    """The retry policy."""

    attempts: int = 3

After

Docstring records an invariant

app/policy.py · focus
class RetryPolicy:
    """Retry policy required because the upstream caps concurrency."""

    attempts: int = 3

Limits

  • Schema-carrying bases and decorators, runtime-consumed prompt decorators, generated files, and docstring-only class bodies are excluded.
  • The rule compares conservative word stems; a novel term keeps the docstring.