sphinx-autodoc-typehints 3.17.4


pip install sphinx-autodoc-typehints

  Latest version

Released: Oct 27, 2026


Meta
Author: Bernát Gábor
Maintainer: Bernát Gábor
Requires Python: >=3.12

Classifiers

Development Status
  • 5 - Production/Stable

Framework
  • Sphinx
  • Sphinx :: Extension

Intended Audience
  • Developers

Operating System
  • OS Independent

Programming Language
  • Python
  • Python :: 3 :: Only
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14
  • Python :: 3.15

Topic
  • Documentation
  • Documentation :: Sphinx
  • Software Development :: Documentation

Typing
  • Typed
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.

3.17.4 Oct 27, 2026
3.17.3 Oct 27, 2026
3.17.2 Oct 17, 2026
3.17.1 Oct 17, 2026
3.17.0 Oct 17, 2026
3.16.0 Oct 17, 2026
3.15.0 Oct 16, 2026
3.14.0 Oct 16, 2026
3.13.10 Oct 13, 2026
3.13.9 Oct 06, 2026
3.13.8 Sep 29, 2026
3.13.7 Sep 18, 2026
3.13.6 Sep 08, 2026
3.13.5 Sep 01, 2026
3.13.4 Aug 24, 2026
3.13.3 Aug 24, 2026
3.13.2 Aug 03, 2026
3.13.1 Aug 03, 2026
3.13.0 Jul 21, 2026
3.12.1 Jul 03, 2026
3.12.0 Jun 25, 2026
3.11.1 Jul 15, 2026
3.11.0 Jun 11, 2026
3.10.6 Jun 11, 2026
3.10.5 Jun 03, 2026
3.10.4 May 31, 2026
3.10.3 May 28, 2026
3.10.2 Apr 15, 2026
3.10.1 Apr 13, 2026
3.10.0 Apr 09, 2026
3.9.11 Mar 24, 2026
3.9.10 Mar 23, 2026
3.9.9 Mar 20, 2026
3.9.8 Mar 09, 2026
3.9.7 Mar 05, 2026
3.9.6 Mar 04, 2026
3.9.5 Mar 02, 2026
3.9.4 Mar 02, 2026
3.9.3 Mar 02, 2026
3.9.2 Mar 01, 2026
3.9.1 Mar 01, 2026
3.9.0 Mar 01, 2026
3.8.0 Feb 25, 2026
3.7.0 Feb 23, 2026
3.6.3 Feb 18, 2026
3.6.2 Jan 02, 2026
3.6.1 Jan 02, 2026
3.6.0 Dec 09, 2025
3.5.2 Oct 16, 2025
3.5.1 Oct 09, 2025
3.5.0 Oct 09, 2025
3.4.0 Oct 08, 2025
3.3.0 Oct 08, 2025
3.2.0 Apr 25, 2025
3.1.0 Feb 19, 2025
3.0.1 Jan 16, 2025
3.0.0 Jan 03, 2025
2.5.0 Oct 09, 2024
2.4.4 Sep 18, 2024
2.4.3 Sep 17, 2024
2.4.2 Sep 17, 2024
2.4.1 Sep 12, 2024
2.4.0 Sep 07, 2024
2.3.0 Aug 29, 2024
2.2.3 Jul 17, 2024
2.2.2 Jun 22, 2024
2.2.1 Jun 21, 2024
2.2.0 Jun 19, 2024
2.1.1 Jun 04, 2024
2.1.0 Apr 17, 2024
2.0.1 Apr 10, 2024
2.0.0 Feb 08, 2024
1.25.3 Jan 26, 2024
1.25.2 Nov 11, 2023
1.25.1 Nov 10, 2023
1.25.0 Nov 09, 2023
1.24.1 Oct 31, 2023
1.24.0 Jul 21, 2023
1.23.4 Jan 18, 2023
1.23.3 Jun 27, 2023
1.23.2 Jun 16, 2023
1.23.1 Jun 15, 2023
1.23.0 Apr 13, 2023
1.22 Jan 30, 2023
1.21.8 Jan 24, 2023
1.21.7 Jan 20, 2023
1.21.6 Jan 20, 2023
1.21.5 Jan 19, 2023
1.21.4 Jan 18, 2023
1.21.3 Jan 17, 2023
1.21.2 Jan 17, 2023
1.21.1 Jan 16, 2023
1.21.0 Jan 16, 2023
1.20.2 Jan 13, 2023
1.20.1 Jan 06, 2023
1.20.0 Jan 05, 2023
1.19.5 Nov 02, 2022
1.19.4 Sep 27, 2022
1.19.3 Sep 26, 2022
1.19.2 Aug 08, 2022
1.19.1 Jul 31, 2022
1.19.0 Jul 27, 2022
1.18.3 Jun 10, 2022
1.18.2 Jun 03, 2022
1.18.1 Apr 13, 2022
1.18.0 Apr 12, 2022
1.17.1 Apr 12, 2022
1.17.0 Feb 11, 2022
1.16.0 Jan 25, 2022
1.15.3 Jan 18, 2022
1.15.2 Jan 11, 2022
1.15.1 Jan 10, 2022
1.15.0 Jan 10, 2022
1.14.1 Jan 07, 2022
1.14.0 Jan 06, 2022
1.13.1 Jan 04, 2022
1.13.0 Jan 01, 2022
1.12.0 Apr 15, 2021
1.11.1 Oct 12, 2020
1.11.0 Jun 21, 2020
1.10.3 Nov 11, 2019
1.10.2 Nov 05, 2019
1.10.1 Nov 04, 2019
1.10.0 Nov 03, 2019
1.9.0 Oct 25, 2019
1.8.0 Sep 12, 2019
1.7.0 Jul 24, 2019
1.6.0 Dec 23, 2018
1.5.2 Dec 02, 2018
1.5.1 Nov 20, 2018
1.5.0 Nov 14, 2018
1.4.0 Nov 10, 2018
1.3.0 Mar 18, 2018
1.2.5 Feb 12, 2018
1.2.4 Jan 17, 2018
1.2.3 Aug 26, 2017
1.2.1 Jul 31, 2017
1.2.0 Mar 26, 2017
1.1.0 Aug 18, 2016
1.0.6 May 08, 2016
1.0.5 May 03, 2016
1.0.4 Apr 08, 2016
1.0.3 Nov 19, 2015
1.0.2 Oct 31, 2015
1.0.1 Sep 22, 2015
1.0.0 Sep 21, 2015
Extras: None
Dependencies:
sphinx (>=9.1)
typing-extensions (>=4.16)