sphinx
sphinx copied to clipboard
Sphinx build stuck in reading sources... when `singledispatch` and `autodoc_mock_imports` are used
Describe the bug
Sphinx build hangs forever (until it times out) if autodoc_mock_imports is used with code that uses singledispatch.
How to Reproduce
See this repository and its GitHub Actions to reproduce the issue: https://github.com/rozsasarpi/sphinx_singledispatch
- stuck build (timed out) when
singledispatchandautodoc_mock_importsare both used: https://github.com/rozsasarpi/sphinx_singledispatch/runs/6999430788?check_suite_focus=true#step:5:15 - working build without
autodoc_mock_imports: https://github.com/rozsasarpi/sphinx_singledispatch/runs/6999461954?check_suite_focus=true - working build without
singledispatch: https://github.com/rozsasarpi/sphinx_singledispatch/runs/6999520591?check_suite_focus=true
Expected behavior
make html finishes the build.
Your project
https://github.com/rozsasarpi/sphinx_singledispatch
Screenshots

OS
Linux/Win
Python version
3.8, 3.9
Sphinx version
5.0.2/4.5.0
Sphinx extensions
sphinx.ext.autodoc, myst_parser
Extra tools
No response
Additional context
No response
We are having the identical problem: https://github.com/scverse/rapids_singlecell/pull/180
We bring in a bunch of GPU deps via autodoc_mock_imports and we use singledispatch in a private function. The whole process hangs before it even starts to build.