skillfed

docstring-inheritance

Avoid writing and maintaining duplicated docstrings.

docstring-inheritance v3.0.0 93.6K downloads/30d#13,377 on PyPI35
Permissive license MIT Active released

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-inheritance

uv

uv add docstring-inheritance

poetry

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 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

Operating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

docstring inheritance pythonavoid duplicate docstringsautomatic docstring inheritancenumpy google docstring formatclass docstring inheritancedocumentation inheritancedocstring reuse
docstring-managementdocumentation-automationsphinx-mkdocs

More Documentation packages