Skip to content

no-copied-inherited-docstring

An override repeats the documentation of the single local base method it actually overrides.

Why

Inherited documentation is available through inspect.getdoc and help, while a duplicate can drift. Direct Child.method.__doc__ consumers remain a reason to retain and suppress the copy.

Fix

Delete the copied docstring only when the base contract is complete and no runtime or generated-documentation consumer requires direct __doc__. Keep override-specific behavior in the override docstring.

Examples

Before — flagged Override repeats its base method documentation
app/store.py
class Store:
def get(self, key: str) -> str:
"""Get a value by key."""
return key
class MemoryStore(Store):
def get(self, key: str) -> str:
"""Get a value by key."""
return key
After — preferred Override documents its implementation-specific behavior
app/store.py
class Store:
def get(self, key: str) -> str:
"""Get a value by key."""
return key
class MemoryStore(Store):
def get(self, key: str) -> str:
"""Read the process-local cache before the base backend."""
return key

Formerly: duplicated-override-docstring