sphinx-doc / sphinx-doc/sphinx
Sphinx build stuck in reading sources... when `singledispatch` and `autodoc_mock_imports` are used
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked sphinx_singledispatch reproduction repository and run its make html build using both singledispatch and autodoc_mock_imports. Compare it with the working builds that omit one of those features, then trace the sphinx.ext.autodoc processing involved. Done means the combined configuration completes instead of hanging while reading sources.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100