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

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.2
File Size Uploaded Provenance
sphinx_autodoc_typehints-3.17.2.tar.gz 570.8 kB With provenance Details

Built distribution (wheel)

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

Total release size: 711.1 kB

Release files / sphinx_autodoc_typehints-3.17.2.tar.gz

Download URL sphinx_autodoc_typehints-3.17.2.tar.gz
Size 570.8 kB
Tags Source
SHA-256 checksum
How to use checksums
de41ed4001f4818bb6d37c22fd10ee44a93e6c8e945c6c7e3984e28a9df87d1c
BLAKE2b-256 checksum
How to use checksums
9cfac967fd665cc102c90338a90292aba336f852ee6f9b3477ffe4da565edb11
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 17, 2026.

Transparency log

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

Download URL sphinx_autodoc_typehints-3.17.2-py3-none-any.whl
Size 140.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0ad1f96503d69b63c2a1c043f12e2a727c9549e6503d4adbf2125dbf5ff50ed
BLAKE2b-256 checksum
How to use checksums
78d48fc500ff2fafe8a6e1847abd8b1072494dc1a5f136f8e890e973db7de4eb
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 17, 2026.

Transparency log

Security for sphinx-autodoc-typehints 3.17.2

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.2.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 17, 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.

Release history Release notifications | RSS feed

This release

3.17.2 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