-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Labels
Description
Describe the bug
Modules mocked with autodoc_mock_imports don't support | for type hinting, when used as e.g. type hints in function's parameters.
How to Reproduce
# conf.py
autodoc_mock_imports = [ 'mock_module' ]# somewhere in the API
def func_to_autodoc(
myclass1: Optional[mock_module.MyClass] = None, # OK
myclass2: mock_module.MyClass | None = None, # Fails with | not supported
): ...Environment Information
Platform: darwin; (macOS-26.2-arm64-arm-64bit)
Python version: 3.11.14 | packaged by conda-forge | (main, Oct 22 2025, 22:56:31) [Clang 19.1.7 ])
Python implementation: CPython
Sphinx version: 8.2.3
Docutils version: 0.21.2
Jinja2 version: 3.1.6
Pygments version: 2.19.2
Sphinx extensions
extensions = [
'sphinx.ext.autodoc',
]Additional context
No response
Reactions are currently unavailable