Registry / web-framework / sphinx-autodoc-typehints

sphinx-autodoc-typehints

JSON →
library3.13.4pypypi✓ verified 24d ago

sphinx-autodoc-typehints is a Sphinx extension that provides full support for type hints (PEP 484) in the documentation generated by `sphinx.ext.autodoc`. It parses type annotations from Python code and renders them beautifully in reStructuredText or Markdown output. The current version is 3.9.11, and it follows a minor release cadence driven by bug fixes and compatibility with new Sphinx or Python versions.

pip install sphinx-autodoc-typehints
INSTALL
IMPORT
SIG · SPHINX-AUTODOC-TYP
S
sphinx-autodoc-typehints
web-frameworkpythonv3.13.4
Install
5.4s avg
Import
Disk
95MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 92.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.4s · import 0.000s · 93MB
95MB installed
● package 95MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sphinx_autodoc_typehints
extensions = [ 'sphinx.ext.autodoc', 'sphinx_autodoc_typehints' ]
extensions = ['sphinx_autodoc_typehints', 'sphinx.ext.autodoc']
Sphinx extensions are enabled by adding their string name to the 'extensions' list in conf.py. `sphinx.ext.autodoc` must be loaded *before* `sphinx_autodoc_typehints` to function correctly.

To quickly integrate `sphinx-autodoc-typehints` into your project, ensure `sphinx.ext.autodoc` is enabled in your `conf.py` first, then add `'sphinx_autodoc_typehints'` to the `extensions` list. This snippet shows a minimal `conf.py` setup, including common configuration options. Create a Python module with type-hinted functions/classes, then use `automodule` directives in your `.rst` files to generate documentation.

import os # conf.py example # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath. import sys sys.path.insert(0, os.path.abspath('.')) project = 'My Project' copyright = '2024, Author Name' author = 'Author Name' release = '0.1' extensions = [ 'sphinx.ext.autodoc', 'sphinx_autodoc_typehints' # Add this extension ] # Optional: Configure the extension typehints_fully_qualified = False # This option was removed in v3.0.0 (example of a common mistake for older configs) typehints_document_rtype = True # Explicitly document return types # Example Python module (my_module.py) # def greet(name: str, age: int = 30) -> str: # """Greets a person. # # :param name: The name of the person. # :param age: The age of the person. # :return: A greeting message. # """ # return f"Hello, {name}! You are {age} years old."
Debug
Known issues
breakingVersion 3.0.0 and newer require Python 3.12+ and Sphinx 6.0+. If you are on an older Python version, you must use `sphinx-autodoc-typehints<3`.
fix
Upgrade your Python environment to 3.12+, or pin the library version to `<3` (e.g., `pip install 'sphinx-autodoc-typehints<3'`).
affects: >=3.0.0
breakingConfiguration options `always_document_param_types` and `typehints_fully_qualified` were removed in version 3.0.0. Using them will result in a Sphinx warning about unknown configuration values and these settings will be ignored.
fix
Remove these options from your `conf.py`. The `typehints_fully_qualified` option functionality is largely superseded by Sphinx's own type resolution improvements.
affects: >=3.0.0
gotcha`sphinx.ext.autodoc` must be enabled and loaded *before* `sphinx_autodoc_typehints` in your `conf.py` `extensions` list for type hints to be correctly processed.
fix
Ensure `extensions = ['sphinx.ext.autodoc', 'sphinx_autodoc_typehints']` (or similar order) is used in your `conf.py`.
affects: All versions
gotchaThe default value for the `typehints_document_rtype` configuration option changed from `True` to `False` in version 3.0.0. This means return types are no longer documented by default.
fix
If you wish to continue documenting return types, explicitly set `typehints_document_rtype = True` in your `conf.py`.
affects: >=3.0.0
Upgrade
Version history
3.13.4latest on PyPI · released Aug 24, 2026
Audit
Dependencies
SphinxrequiredThis is a Sphinx extension and requires Sphinx to function.
PythonrequiredRequires Python 3.12 or newer. Previous versions (e.g., <3.0.0) supported older Python versions.
Agent activity
3 hits · last 30 days
node
2
Resources
sphinx-autodoc-typehints — pip install sphinx-autodoc-typehints · libregistry