--- id: docstring-inheritance version: "3.0.0" license: MIT license_treatment: permissive maintenance: active --- # docstring-inheritance — Avoid writing and maintaining duplicated docstrings. License: permissive · Maintenance: active · Downloads: 93.6K/mo ## 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 above — 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 pip install docstring-inheritance uv add docstring-inheritance poetry add docstring-inheritance ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 93.6K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags docstring inheritance python, avoid duplicate docstrings, automatic docstring inheritance, numpy google docstring format, class docstring inheritance, documentation inheritance, docstring reuse, docstring-management, documentation-automation, sphinx-mkdocs [View on SkillFed](https://skillfed.io/packages/docstring-inheritance) · [View on PyPI](https://pypi.org/project/docstring-inheritance/)