skillfed

sphinx-autodoc-typehints

Type hints (PEP 484) support for the Sphinx autodoc extension

sphinx-autodoc-typehints v3.13.2 9.5M downloads/30d#1,530 on PyPI587
Permissive license MIT Active released

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

uv

uv add sphinx-autodoc-typehints

poetry

poetry add sphinx-autodoc-typehints

Installing 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

Development Status :: 5 - Production/StableFramework :: Sphinx :: ExtensionIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Topic :: Documentation :: Sphinx

Tags

sphinx type hints documentationautodoc type annotationspython type hints sphinxautomatic type documentationsphinx extension type hintspep 484 sphinx autodoctype annotation docs generator
sphinx-extensiontype-hintsapi-docs

More Sphinx packages

docstring-parser

Parses Python docstrings in ReST, Google,…

permissive · top 1,000 on PyPI

Sphinx

Sphinx generates professional documentation…

permissive · top 1,000 on PyPI

sphinxcontrib-serializinghtml

A Sphinx extension that outputs documentation…

permissive · top 1,000 on PyPI

alabaster

Alabaster is a clean, responsive Sphinx theme…

permissive · top 1,000 on PyPI

sphinxcontrib-htmlhelp

A Sphinx extension that generates HTML help…

permissive · top 1,000 on PyPI

sphinxcontrib-qthelp

A Sphinx extension that converts documentation…

permissive · top 1,000 on PyPI

autodoc_pydantic

Sphinx extension that automatically generates…

permissive · top 15,000 on PyPI

sphinx-autoapi

Sphinx AutoAPI generates complete API…

permissive · top 5,000 on PyPI

autodocsumm

A Sphinx extension that enhances autodoc with…

permissive · top 5,000 on PyPI

sphinx-autodoc2

sphinx-autodoc2 generates API documentation for…

permissive · top 15,000 on PyPI

sphinxcontrib-django

A Sphinx extension that enhances autodoc output…

permissive · top 15,000 on PyPI

autoclasstoc

Generates a structured table of contents for…

unclear · top 15,000 on PyPI

readthedocs-sphinx-search

A Sphinx extension that adds real-time…

permissive · top 15,000 on PyPI

sphinx_tippy

Adds interactive tooltips to Sphinx…

permissive · top 15,000 on PyPI

sphinx-click

Sphinx-click is a Sphinx extension that…

permissive · top 15,000 on PyPI

sphinxcontrib-napoleon

A Sphinx extension that converts Google and…

permissive · top 15,000 on PyPI