docstring-inheritance
Avoid writing and maintaining duplicated docstrings.
What it is and what it does
docstring-inheritance is a Python package that automatically propagates docstrings from parent classes to their subclasses, reducing the need to write and maintain duplicate documentation. It understands both NumPy and Google docstring formats and handles inheritance at the section level—for example, inheriting individual parameter descriptions while allowing child classes to override or add new ones. The package uses metaclasses to intercept class creation and applies inheritance only when explicitly enabled via an environment variable, so it has negligible performance cost during normal runtime.
The package is designed to integrate with documentation build tools like Sphinx and mkdocs. It handles complex inheritance patterns, including multiple and multi-level inheritance, and can inherit docstrings for functions, methods, class methods, static methods, and properties. It also supports abstract base classes when combined with abc.ABCMeta, and can warn about missing parameter descriptions when configured.
Use it for:
- Automatically populate child class docstrings during Sphinx or mkdocs documentation builds without manually repeating parent descriptions.
- Maintain consistent parameter documentation across a class hierarchy where child methods override parent signatures.
- Detect and report duplicated or similar docstring sections that could be consolidated through inheritance.
- Build libraries with deep inheritance hierarchies where manual docstring duplication becomes a maintenance burden.
- Ensure parameter documentation stays synchronized when child classes add or remove arguments from inherited methods.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Automatically inherits docstrings from parent classes to child classes, eliminating duplicate documentation while supporting NumPy and Google docstring formats.
Yes, if you maintain a Python library with class hierarchies and use Sphinx or mkdocs for documentation. The package is actively maintained, has no known vulnerabilities, and solves a real documentation maintenance problem with minimal runtime overhead. Install it in your documentation build environment and enable it only during doc generation. Not necessary for projects with shallow hierarchies or those that don't use structured docstring formats.
Install
docstring-inheritance on PyPI
pip
pip install docstring-inheritanceuv
uv add docstring-inheritancepoetry
poetry add docstring-inheritanceInstalling docstring-inheritance
Before you install
Low install friction with a single runtime dependency (typing-extensions). The package is actively maintained with a recent release and supports modern Python versions (3.10–3.14).
License in practice
MIT license permits commercial and private use with minimal restrictions; suitable for most projects.
Quickstart
pip install docstring-inheritance
from docstring_inheritance import NumpyDocstringInheritanceMeta
class Parent(metaclass=NumpyDocstringInheritanceMeta):
def method(self, x):
"""Summary.\n\n Parameters\n ----------\n x:\n Description.
"""
class Child(Parent):
def method(self, x):
"""Additional notes."""
Requires Python 3.10 or later; docstring inheritance is only applied when the environment variable DOCSTRING_INHERITANCE_ENABLE=1 is set (typically during documentation builds).
Verify before relying
- Whether the package works correctly with all Sphinx and mkdocs configurations without additional setup beyond setting the environment variable.
- Performance impact when inheritance is enabled on large codebases with deep inheritance hierarchies.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4,>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing-extensions |
| Maintenance | actively maintained — 246 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 93,555/month — #13,377 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: docstring_inheritance-3.0.0-py3-none-any.whl
Tags
More Documentation packages
Docutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
SphinxSphinx generates professional documentation…
permissive · top 1,000 on PyPI
griffeGriffe extracts the complete structure and…
permissive · top 1,000 on PyPI
sphinxcontrib-serializinghtmlA Sphinx extension that outputs documentation…
permissive · top 1,000 on PyPI
alabasterAlabaster is a clean, responsive Sphinx theme…
permissive · top 1,000 on PyPI
sphinxcontrib-htmlhelpA Sphinx extension that generates HTML help…
permissive · top 1,000 on PyPI
abstractcpAllows you to define abstract class properties…
permissive · top 15,000 on PyPI
AcquisitionAcquisition implements a mechanism for Python…
unclear · top 15,000 on PyPI
docrepDocrep provides utilities to intelligently…
permissive · top 15,000 on PyPI
overridesProvides a @override decorator that validates…
permissive · top 1,000 on PyPI
docstr-coverageMeasures docstring coverage in Python source…
permissive · top 15,000 on PyPI
slotscheckValidates that `__slots__` are correctly…
permissive · top 15,000 on PyPI
docstring-parserParses Python docstrings in ReST, Google,…
permissive · top 1,000 on PyPI
docstring-parser-forkParses Python docstrings in ReST, Google,…
permissive · top 5,000 on PyPI
mkdocstrings-pythonGenerates API documentation for Python projects…
permissive · top 5,000 on PyPI
numpydocA Sphinx extension that parses and renders…
permissive · top 5,000 on PyPI