Skip to main content
sphinx-autodoc-typehints

sphinx-autodoc-typehints

PyPI Supported Python versions Documentation status Downloads check

This Sphinx extension reads the type hints of the code autodoc documents and writes them into the parameter and return fields, so you state each type once, in the code. It links every part of a type to its documentation, and resolves names your code imports only for type checkers (inside an if TYPE_CHECKING: block) or declares in .pyi stub files. It also documents @overload variants and default values, and types Google and NumPy style docstrings written for napoleon or numpydoc.

pip install sphinx-autodoc-typehints
# conf.py: load autodoc first, then this extension
extensions = ["sphinx.ext.autodoc", "sphinx_autodoc_typehints"]

Why not Sphinx's built-in autodoc_typehints?

Sphinx's autodoc_typehints = "description" already moves annotations into the parameter and return fields, links them, and works with napoleon docstrings and type comments. If your annotations resolve at runtime and you use Sphinx fields or napoleon, that setting may be enough.

Show example code and configuration

The same demo.py below renders differently with each option. It uses typing-extensions for Doc. Both builds use .. automodule:: demo with :members:. The left adds typehints_defaults = "braces" and always_document_param_types = True to the configuration above; the right loads only sphinx.ext.autodoc with autodoc_typehints = "description".

from __future__ import annotations

from typing import Annotated, Literal, NotRequired, TypedDict, Unpack, overload

from typing_extensions import Doc


class Options(TypedDict):
    """Optional controls for a request."""

    retries: NotRequired[int]
    trace: NotRequired[bool]


@overload
def fetch(path: str, *, mode: Literal["text"], **options: Unpack[Options]) -> str: ...


@overload
def fetch(path: str, *, mode: Literal["bytes"], **options: Unpack[Options]) -> bytes: ...


def fetch(
    path: Annotated[str, Doc("resource path")],
    *,
    mode: Literal["text", "bytes"] = "text",
    **options: Unpack[Options],
) -> str | bytes:
    """Fetch a resource.

    :keyword retries: attempts after a failure
    :keyword trace: log each request
    """
    return "" if mode == "text" else b""

This extension puts overloads in a field, types the retries and trace keywords, and turns Annotated Doc into a path description. Built-in Sphinx keeps the overloads in signatures and leaves those keyword descriptions untyped.

The live TypedDict example lets you change the configuration and inspect its output. See the examples for each difference:

The full comparison lists the differences, and the live examples show each module rendered both ways.

The typing features gallery shows source and rendered output for each construct. The documentation also has a tutorial, how-to guides and the option reference; CONTRIBUTING.md explains how to work on the extension.

Metadata

Release files for sphinx-autodoc-typehints 3.17.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sphinx-autodoc-typehints 3.17.3
File Size Uploaded Provenance Actions
sphinx_autodoc_typehints-3.17.3.tar.gz 510.8 kB With provenance Details for sphinx_autodoc_typehints-3.17.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sphinx-autodoc-typehints 3.17.3
File Interpreter ABI Platform Actions
sphinx_autodoc_typehints-3.17.3-py3-none-any.whl Python 3 none any Details for sphinx_autodoc_typehints-3.17.3-py3-none-any.whl

Total release size: 651.1 kB

Release files / sphinx_autodoc_typehints-3.17.3.tar.gz

Download URL sphinx_autodoc_typehints-3.17.3.tar.gz
Size 510.8 kB
Tags Source
SHA-256 checksum
How to use checksums
bb61ba0e2ab46e24631b0cc6ea0818176d6218a35225e0e632586e8dffc4ff4d
BLAKE2b-256 checksum
How to use checksums
5b8c2ab7bd22aa2988c9e4f4791688d6de24a00395afbd5d7dffa16b35db81fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / sphinx_autodoc_typehints-3.17.3-py3-none-any.whl

Download URL sphinx_autodoc_typehints-3.17.3-py3-none-any.whl
Size 140.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a87c08a7fe562a50557d1be6715bd47d403c23a7ead932dfc96de709b8a2b8ba
BLAKE2b-256 checksum
How to use checksums
839eab4db759c0a8dbc37aef2993976db7874bb2bde5f719d3c5b3448022f0d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for sphinx-autodoc-typehints 3.17.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sphinx_autodoc_typehints-3.17.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.17.3 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page