sphinx-autodoc-typehints
Type hints (PEP 484) support for the Sphinx autodoc extension
What it is and what it does
sphinx-autodoc-typehints is a Sphinx extension that reads Python type annotations from your source code and automatically incorporates them into your generated API documentation. Instead of writing types twice—once in code annotations and again in docstrings—you write them once in your function signatures and let the extension handle the rest. It resolves types from TYPE_CHECKING blocks and .pyi stub files, renders @overload signatures, extracts types from attrs and dataclass classes, and handles both Google and NumPy docstring styles.
The extension integrates directly into your Sphinx build pipeline through sphinx.ext.autodoc. It offers fine-grained control over how types appear in your output: you can choose union display style (Union[X, Y] vs X | Y), show or hide return types, display default parameter values, and apply custom type formatters. It also automatically fixes cross-references for standard library types whose runtime module differs from their documented path, reducing manual link corrections in your docs.
Use it for:
- Maintain API documentation for a library without duplicating type information between code and docstrings.
- Generate type-annotated docs for attrs or dataclass-heavy projects automatically.
- Support multiple docstring styles (Google, NumPy, reStructuredText) while keeping types in sync.
- Display @overload signatures in your docs to show all valid function call patterns.
- Control union type rendering to match your project's style guide (Union syntax vs pipe syntax).
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Automatically extracts Python type hints from your code and injects them into Sphinx-generated documentation, eliminating the need to duplicate type information in docstrings.
Yes. This is a stable, actively maintained extension (release 11 days ago, 587 stars) with low install friction and no known vulnerabilities. It solves a real problem—eliminating type duplication between code and docs—and is widely used (top 5000 on PyPI). MIT license poses no restrictions. Install it if you use Sphinx and want your type hints to flow automatically into your documentation.
Install
sphinx-autodoc-typehints on PyPI
pip
pip install sphinx-autodoc-typehintsuv
uv add sphinx-autodoc-typehintspoetry
poetry add sphinx-autodoc-typehintsInstalling sphinx-autodoc-typehints
Before you install
Low friction: pure Python wheel with a single runtime dependency on sphinx. Active maintenance with a release 11 days ago and 587 repository stars.
License in practice
MIT license permits commercial and private use with minimal restrictions—suitable for most projects.
Quickstart
pip install sphinx-autodoc-typehints
# In conf.py:
extensions = ["sphinx.ext.autodoc", "sphinx_autodoc_typehints"]
# In your code:
def format_unit(value: float, unit: str) -> str:
"""Format a value with its unit."""
return f"{value} {unit}"
Requires Python 3.12 or later and an existing Sphinx documentation setup.
Verify before relying
- Whether the extension handles all edge cases in complex type hierarchies (e.g., deeply nested generics, forward references).
- Performance impact when processing large codebases with thousands of annotated functions.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.12) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — sphinx |
| Maintenance | actively maintained — 11 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 9,483,648/month — #1,530 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sphinx_autodoc_typehints-3.13.2-py3-none-any.whl
Keywords: environments, isolated, testing, virtual
Tags
More Sphinx packages
Parses Python docstrings in ReST, Google,…
permissive · top 1,000 on PyPI
SphinxSphinx generates professional documentation…
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
sphinxcontrib-qthelpA Sphinx extension that converts documentation…
permissive · top 1,000 on PyPI
autodoc_pydanticSphinx extension that automatically generates…
permissive · top 15,000 on PyPI
sphinx-autoapiSphinx AutoAPI generates complete API…
permissive · top 5,000 on PyPI
autodocsummA Sphinx extension that enhances autodoc with…
permissive · top 5,000 on PyPI
sphinx-autodoc2sphinx-autodoc2 generates API documentation for…
permissive · top 15,000 on PyPI
sphinxcontrib-djangoA Sphinx extension that enhances autodoc output…
permissive · top 15,000 on PyPI
autoclasstocGenerates a structured table of contents for…
unclear · top 15,000 on PyPI
readthedocs-sphinx-searchA Sphinx extension that adds real-time…
permissive · top 15,000 on PyPI
sphinx_tippyAdds interactive tooltips to Sphinx…
permissive · top 15,000 on PyPI
sphinx-clickSphinx-click is a Sphinx extension that…
permissive · top 15,000 on PyPI
sphinxcontrib-napoleonA Sphinx extension that converts Google and…
permissive · top 15,000 on PyPI