You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sphinx 7.4.6: autosummary: Failed to import module #12660
Is there any chance this change would have introduced a warning by mistake? We use our own module.rst and class.rst templates, but they look awfully similar to the ones here.
We're seeing:
Warning, treated as error:
[autosummary] failed to import foo.
Possible hints:
* ModuleNotFoundError: No module named 'foo'
* KeyError: 'foo'
* ValueError: not enough values to unpack (expected 2, got 1)
good chance this is user-error, but thought I would ask (it does work just before 7.4.6)!
Hi Michael (@mwalsh161), thanks for writing. I haven't had any further reports of issues, so my first instinct would be to suspect the templates. The ValueError re unpacking also looks interesting.
Are you able to share either your project or a minimal reporoducer so that we might investigate?
I am also seeing this issue, I believe there was a change between versions 7.3.7 and 7.4.6, which causes documentation table of contents not to be generated.
I get similar warnings e.g.
WARNING: [autosummary] failed to import i03.
Possible hints:
* ValueError: not enough values to unpack (expected 2, got 1)
* KeyError: 'i03'
* ModuleNotFoundError: No module named 'i03'
Thanks, @AA-Turner, this install worked. Unfortunately, I'm getting the same error as with 7.4.5 and 7.4.6, i.e.,
Warning, treated as error:
Summarised items should not include the current module. Replace 'skimage.color' with 'color'.
[autosummary.import_cycle]
make: *** [Makefile:50: html] Error 2
Apologies for the delayed response (pinning sphinx was fine for quite some time so we just revisited updating again after the major release). Sphinx 8.2.6 still has this regression.
Whatever change occurred seems to no longer allow autosummary to come before automodule in the module.rst template (I noticed @kevalmorabia97 has the same ordering which is likely no coincidence).
This was our only reason for overriding the template in the first place.
We are also seeing this warning in Sphinx 8.2.3, when trying to get rid of the warning from #12589
WARNING: Summarised items should not include the current module. Replace 'cylc.flow.main_loop.auto_restart' with 'auto_restart'. [autosummary.import_cycle]
We have
Main Loop Plugins
=================
.. automodule:: cylc.flow.main_loop
WARNING: autodoc: failed to import module 'auto_restart'; the following exception was raised:
['Traceback (most recent call last):\n', ' File ".../lib/python3.13/site-packages/sphinx/ext/autodoc/importer.py", line 269, in import_object\n module = import_module(modname, try_reload=True)\n', ' File ".../lib/python3.13/site-packages/sphinx/ext/autodoc/importer.py", line 172, in import_module\n raise ModuleNotFoundError(msg, name=modname) # NoQA: TRY301\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', "ModuleNotFoundError: No module named 'auto_restart'\n"] [autodoc.import_object]
We ran into the same error as in the OP breaking the build of the Spyder API docs when trying to customize the template to put the modules block first, and can confirm we can repro it in Sphinx 8.2.3 (current stable as of this writing) with the default template by simply moving the modules block with the autosummary directive to above the automodule directive.
As it seems clearly desirable that a summary table of a module's immediate children belongs near the top where it is easily accessible rather than buried all the way at the bottom of the module's content (not sure why the default template has it seemingly backwards to begin with), this is a pretty important issue for us.
Given the error message doesn't appear to give much obvious insight on what's going on here, I'm not really sure where to start debugging this, but @AA-Turner if you are able to point me in the right direction, I might be able to take a crack at it.
@AA-Turner I had to do a bit of hackery to get Sphinx 9 to work with that project (as it is partially MyST-based, which doesn't officially support Sphinx 9 yet), but running 9.0.0rc1 with --show-traceback doesn't apparently produce a traceback, just the same messages as before. I also tried with and without -W, -E, -a, and --keep-going but it made no different to showing the traceback, and confirmed autodoc_warningiserror is True; I didn't see any other autodoc or autosummary settings that seemed relevant to not showing the traceback. Am I missing something here?
Full output
$ nox -s cleannox > Running session cleanRemoving generated directory 'D:/Repos/Spyder/spyder-api-docs/docs/_build'Removing generated directory 'D:/Repos/Spyder/spyder-api-docs/docs/_autosummary'nox > Session clean was successful.
$ nox -s build -- --show-traceback -t autodocnox > Running session buildnox > Session build was successful.nox > Running session _executenox > Reusing existing virtual environment at .nox\_execute.nox > python -I -m sphinx -b html -W --keep-going --show-traceback -t autodoc -- 'D:\Repos\Spyder\spyder-api-docs\docs' 'D:\Repos\Spyder\spyder-api-docs\docs\_build\html'Running Sphinx v9.0.0rc1loading translations [en]... donemaking output directory... done[autosummary] generating autosummary for: index.rst, plugin_development.rst, reference.rst[autosummary] generating autosummary for: D:\Repos\Spyder\spyder-api-docs\docs\_autosummary\spyder.api.rstWARNING: [autosummary] failed to import asyncdispatcher.Possible hints:* ModuleNotFoundError: No module named 'asyncdispatcher'* KeyError: 'asyncdispatcher'* ValueError: not enough values to unpack (expected 2, got 1)WARNING: [autosummary] failed to import config.Possible hints:* KeyError: 'config'* ModuleNotFoundError: No module named 'config'* ValueError: not enough values to unpack (expected 2, got 1)
# Etc for every top-level module and import packageloading intersphinx inventory 'python' from https://docs.python.org/objects.inv ...loading intersphinx inventory 'spyder' from https://docs.spyder-ide.org/current/objects.inv ...intersphinx inventory has moved: https://docs.python.org/objects.inv -> https://docs.python.org/3/objects.invbuilding [mo]: all of 0 po fileswriting output...building [html]: all source filesupdating environment: [new config] 4 added, 0 changed, 0 removedreading sources... [100%] referenceD:\Repos\Spyder\spyder-api-docs\docs\_autosummary\spyder.api.rst:5: WARNING: autosummary: failed to import asyncdispatcher.Possible hints:* ValueError: not enough values to unpack (expected 2, got 1)* KeyError: 'asyncdispatcher'* ModuleNotFoundError: No module named 'asyncdispatcher'D:\Repos\Spyder\spyder-api-docs\docs\_autosummary\spyder.api.rst:5: WARNING: autosummary: failed to import config.Possible hints:* ModuleNotFoundError: No module named 'config'* KeyError: 'config'* ValueError: not enough values to unpack (expected 2, got 1)
# Etc againlooking for now-outdated files... none foundpickling environment... donechecking consistency... donepreparing documents... donecopying assets...copying static files...Writing evaluated template result to D:\Repos\Spyder\spyder-api-docs\docs\_build\html\_static\basic.cssWriting evaluated template result to D:\Repos\Spyder\spyder-api-docs\docs\_build\html\_static\documentation_options.jsWriting evaluated template result to D:\Repos\Spyder\spyder-api-docs\docs\_build\html\_static\language_data.jscopying static files: donecopying extra files...copying extra files: donecopying assets: donewriting output... [100%] referencegenerating indices... genindex py-modindex donehighlighting module code...writing additional pages... search donecopying images... [100%] images/workshop-3/pd_plugin_publish.pngdumping search index in English (code: en)... donedumping object inventory... donebuild finished with problems, 24 warnings (with warnings treated as errors).nox > Command python -I -m sphinx -b html -W --show-traceback -t autodoc -- 'D:\Repos\Spyder\spyder-api-docs\docs' 'D:\Repos\Spyder\spyder-api-docs\docs\_build\html' failed with exit code 1nox > Session _execute failed.nox > Ran multiple sessions:nox > * build: successnox > * _execute: failed
$ nox -s cleannox > Running session cleanRemoving generated directory 'D:/Repos/Spyder/spyder-api-docs/docs/_build'Removing generated directory 'D:/Repos/Spyder/spyder-api-docs/docs/_autosummary'nox > Session clean was successful.(api-docs)CAMGerlach@Vger MINGW64 ~/Dev/Repos/Spyder/spyder-api-docs (revise-top-level-docstrings)
$ nox -s build -- --show-traceback -t autodocnox > Running session buildnox > Session build was successful.nox > Running session _executenox > Reusing existing virtual environment at .nox\_execute.nox > python -I -m sphinx -b html -E -a --show-traceback -t autodoc -- 'D:\Repos\Spyder\spyder-api-docs\docs' 'D:\Repos\Spyder\spyder-api-docs\docs\_build\html'Running Sphinx v9.0.0rc1loading translations [en]... donemaking output directory... done[autosummary] generating autosummary for: index.rst, plugin_development.rst, reference.rst[autosummary] generating autosummary for: D:\Repos\Spyder\spyder-api-docs\docs\_autosummary\spyder.api.rstWARNING: [autosummary] failed to import asyncdispatcher.Possible hints:* KeyError: 'asyncdispatcher'* ValueError: not enough values to unpack (expected 2, got 1)* ModuleNotFoundError: No module named 'asyncdispatcher'WARNING: [autosummary] failed to import config.Possible hints:* KeyError: 'config'* ModuleNotFoundError: No module named 'config'* ValueError: not enough values to unpack (expected 2, got 1)WARNING: [autosummary] failed to import exceptions.Possible hints:* ValueError: not enough values to unpack (expected 2, got 1)* KeyError: 'exceptions'* ModuleNotFoundError: No module named 'exceptions'WARNING: [autosummary] failed to import fonts.Possible hints:* ValueError: not enough values to unpack (expected 2, got 1)* ModuleNotFoundError: No module named 'fonts'* KeyError: 'fonts'WARNING: [autosummary] failed to import plugin_registration.Possible hints:* ValueError: not enough values to unpack (expected 2, got 1)* ModuleNotFoundError: No module named 'plugin_registration'* KeyError: 'plugin_registration'WARNING: [autosummary] failed to import plugins.Possible hints:* ValueError: not enough values to unpack (expected 2, got 1)* ModuleNotFoundError: No module named 'plugins'* KeyError: 'plugins'WARNING: [autosummary] failed to import preferences.Possible hints:* KeyError: 'preferences'* ModuleNotFoundError: No module named 'preferences'* ValueError: not enough values to unpack (expected 2, got 1)WARNING: [autosummary] failed to import shellconnect.Possible hints:* ValueError: not enough values to unpack (expected 2, got 1)* ModuleNotFoundError: No module named 'shellconnect'* KeyError: 'shellconnect'WARNING: [autosummary] failed to import shortcuts.Possible hints:* ValueError: not enough values to unpack (expected 2, got 1)* KeyError: 'shortcuts'* ModuleNotFoundError: No module named 'shortcuts'WARNING: [autosummary] failed to import translations.Possible hints:* ValueError: not enough values to unpack (expected 2, got 1)* KeyError: 'translations'* ModuleNotFoundError: No module named 'translations'WARNING: [autosummary] failed to import utils.Possible hints:* ValueError: not enough values to unpack (expected 2, got 1)* KeyError: 'utils'* ModuleNotFoundError: No module named 'utils'WARNING: [autosummary] failed to import widgets.Possible hints:* KeyError: 'widgets'* ValueError: not enough values to unpack (expected 2, got 1)* ModuleNotFoundError: No module named 'widgets'loading intersphinx inventory 'python' from https://docs.python.org/objects.inv ...loading intersphinx inventory 'spyder' from https://docs.spyder-ide.org/current/objects.inv ...intersphinx inventory has moved: https://docs.python.org/objects.inv -> https://docs.python.org/3/objects.invbuilding [mo]: all of 0 po fileswriting output...building [html]: all source filesupdating environment: [new config] 4 added, 0 changed, 0 removed + Exception Group Traceback (most recent call last): | File "<frozen runpy>", line 198, in _run_module_as_main | File "<frozen runpy>", line 88, in _run_code | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\__main__.py", line 9, in <module> | raise SystemExit(main(sys.argv[1:])) | ^^^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\cmd\build.py", line 493, in main | return build_main(argv) | ^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\cmd\build.py", line 432, in build_main | app.build(args.force_all, args.filenames) | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\application.py", line 436, in build | self.builder.build_all() | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\builders\__init__.py", line 324, in build_all | self.build(None, summary=__('all source files'), method='all') | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\builders\__init__.py", line 408, in build | updated_docnames = set(self.read()) | ^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\builders\__init__.py", line 524, in read | self._read_serial(docnames) | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\builders\__init__.py", line 589, in _read_serial | self.read_doc(docname) | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\builders\__init__.py", line 652, in read_doc | doctree = _parse_str_to_doctree( | ^^^^^^^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\util\docutils.py", line 890, in _parse_str_to_doctree | parser.parse(content, document) | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\parsers.py", line 99, in parse | self.statemachine.run(inputlines, document, inliner=self.inliner) | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\parsers\rst\states.py", line 169, in run | results = StateMachineWS.run(self, input_lines, input_offset, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\statemachine.py", line 233, in run | context, next_state, result = self.check_line( | ^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\statemachine.py", line 445, in check_line | return method(match, context, next_state) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\parsers\rst\states.py", line 2790, in underline | self.section(title, source, style, lineno - 1, messages) | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\parsers\rst\states.py", line 325, in section | self.new_subsection(title, lineno, messages) | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\parsers\rst\states.py", line 391, in new_subsection | newabsoffset = self.nested_parse( | ^^^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\parsers\rst\states.py", line 279, in nested_parse | state_machine.run(block, input_offset, memo=self.memo, | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\parsers\rst\states.py", line 195, in run | results = StateMachineWS.run(self, input_lines, input_offset) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\statemachine.py", line 233, in run | context, next_state, result = self.check_line( | ^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\statemachine.py", line 445, in check_line | return method(match, context, next_state) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\parsers\rst\states.py", line 2359, in explicit_markup | self.explicit_list(blank_finish) | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\parsers\rst\states.py", line 2384, in explicit_list | newline_offset, blank_finish = self.nested_list_parse( | ^^^^^^^^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\parsers\rst\states.py", line 316, in nested_list_parse | state_machine.run(block, input_offset, memo=self.memo, | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\parsers\rst\states.py", line 195, in run | results = StateMachineWS.run(self, input_lines, input_offset) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\statemachine.py", line 233, in run | context, next_state, result = self.check_line( | ^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\statemachine.py", line 445, in check_line | return method(match, context, next_state) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\parsers\rst\states.py", line 2662, in explicit_markup | nodelist, blank_finish = self.explicit_construct(match) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\parsers\rst\states.py", line 2369, in explicit_construct | return method(self, expmatch) | ^^^^^^^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\parsers\rst\states.py", line 2106, in directive | return self.run_directive( | ^^^^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\docutils\parsers\rst\states.py", line 2156, in run_directive | result = directive_instance.run() | ^^^^^^^^^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\ext\autosummary\__init__.py", line 218, in run | items = self.get_items(names) | ^^^^^^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\ext\autosummary\__init__.py", line 323, in get_items | real_name, obj, parent, modname = self.import_by_name( | ^^^^^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\ext\autosummary\__init__.py", line 282, in import_by_name | raise ImportExceptionGroup(exc.args[0], errors) from None | sphinx.ext.autosummary.ImportExceptionGroup: could not import asyncdispatcher (3 sub-exceptions) +-+---------------- 1 ---------------- | Traceback (most recent call last): | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\ext\autosummary\__init__.py", line 709, in _import_by_name | _import_module(modname) | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\ext\autodoc\_dynamic\_importer.py", line 218, in _import_module | raise ModuleNotFoundError(msg, name=modname) # NoQA: TRY301 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ModuleNotFoundError: No module named 'asyncdispatcher' +---------------- 2 ---------------- | Traceback (most recent call last): | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\ext\autosummary\__init__.py", line 724, in _import_by_name | return sys.modules[modname], None, modname | ~~~~~~~~~~~^^^^^^^^^ | KeyError: 'asyncdispatcher' +---------------- 3 ---------------- | Exception Group Traceback (most recent call last): | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\ext\autosummary\__init__.py", line 271, in import_by_name | return import_by_name(name, prefixes) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\ext\autosummary\__init__.py", line 683, in import_by_name | raise ImportExceptionGroup(msg, exceptions) | sphinx.ext.autosummary.ImportExceptionGroup: could not import asyncdispatcher (2 sub-exceptions) +-+---------------- 1 ---------------- | Traceback (most recent call last): | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\ext\autosummary\__init__.py", line 709, in _import_by_name | _import_module(modname) | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\ext\autodoc\_dynamic\_importer.py", line 218, in _import_module | raise ModuleNotFoundError(msg, name=modname) # NoQA: TRY301 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ModuleNotFoundError: No module named 'asyncdispatcher' +---------------- 2 ---------------- | Traceback (most recent call last): | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\ext\autosummary\__init__.py", line 724, in _import_by_name | return sys.modules[modname], None, modname | ~~~~~~~~~~~^^^^^^^^^ | KeyError: 'asyncdispatcher' +------------------------------------ | | During handling of the above exception, another exception occurred: | | Traceback (most recent call last): | File "D:\Repos\Spyder\spyder-api-docs\.nox\_execute\Lib\site-packages\sphinx\ext\autosummary\__init__.py", line 740, in import_ivar_by_name | name, attr = name.rsplit('.', 1) | ^^^^^^^^^^ | ValueError: not enough values to unpack (expected 2, got 1) +------------------------------------nox > Command python -I -m sphinx -b html -E -a --show-traceback -t autodoc -- 'D:\Repos\Spyder\spyder-api-docs\docs' 'D:\Repos\Spyder\spyder-api-docs\docs\_build\html' failed with exit code 1nox > Session _execute failed.nox > Ran multiple sessions:nox > * build: successnox > * _execute: failed
(Just for reference, spyder-api-docs has spyder as a submodule, inside which there is a import package directory spyder, the api subpackage of which is (for now) the top-level autosummary:: target, which in turn contains the above-referenced module asyncdispatcher.)
Can you paste the .. autosummary:: directive itself? It's trying (failing) to import a module asyncdispatcher with no context as to the parent package, so clearly that's getting lost somewhere.
Another thing to try is running with --exception-on-warning -vv, though I don't know what (if anything) the extra verbosity will show.
Top-level reference.rst containing the root autosummary directive:
API Reference
=============
API reference for all modules in the Spyder application.
.. autosummary::
:toctree: _autosummary
:template: custom-module-template.rst
:recursive:
spyder.api
Autosummary directive in the template (only deltas from the default are moved above automodule and aded :template::
.. autosummary::
:toctree::template: custom-module-template.rst
:recursive:
{% for item in modules %}
{{ item }}
{%- endfor %}
Running Sphinx with --exception-on-warning -vv (keeping the patch from before) produced a bunch of informational output, but not much more in terms of details on the error:
Just for reference, here's the output of a successful build with the autosummary block moved back below automodule (with only one -v; -vv on a successful build fills my entire 32k line scrollback buffer and then some):
Thanks, I can confirm that temporary workaround does get the build working again with the autosummary module ToC above the automodule section, although with the undesirable side effect of listing every submodule name in fully qualified form, with a redundant prefix of the current module. Hopefully it helps shed light on the root cause of the issue, where it seems autosummary doesn't know/prepend the current fully qualified module if run before automodule, so it can actually be fixed.
Activity
AA-Turner commentedon Jul 23, 2024
Hi Michael (@mwalsh161), thanks for writing. I haven't had any further reports of issues, so my first instinct would be to suspect the templates. The
ValueErrorre unpacking also looks interesting.Are you able to share either your project or a minimal reporoducer so that we might investigate?
Best,
Adam
rtuck99 commentedon Jul 23, 2024
I am also seeing this issue, I believe there was a change between versions 7.3.7 and 7.4.6, which causes documentation table of contents not to be generated.
I get similar warnings e.g.
Compare the following two github builds:
version 7.3.7
https://github.com/DiamondLightSource/dodal/actions/runs/9891318307/job/27321488418
which builds correctly and generates api documentation:
https://diamondlightsource.github.io/dodal/1.29.3/user/reference/generated/dodal.beamlines.html
version 7.4.6
https://github.com/DiamondLightSource/dodal/actions/runs/10009596477/job/27668842307
which builds documentation that no longer includes the subpackages
https://diamondlightsource.github.io/dodal/1.29.4/user/reference/generated/dodal.beamlines.html
I believe this may be related to change #12609 as the generated sources no longer appear to have prefixes e.g.
AA-Turner commentedon Jul 23, 2024
Also xref scikit-image/scikit-image#7297 (comment) by @mkcor:
kevalmorabia97 commentedon May 7, 2025
Also seeing the issue with Sphinx 7.4.6 on building docs for https://github.com/NVIDIA/TensorRT-Model-Optimizer
Do I need to fix these 2 files?
mwalsh161 commentedon May 10, 2025
Apologies for the delayed response (pinning sphinx was fine for quite some time so we just revisited updating again after the major release). Sphinx 8.2.6 still has this regression.
Whatever change occurred seems to no longer allow autosummary to come before automodule in the
module.rsttemplate (I noticed @kevalmorabia97 has the same ordering which is likely no coincidence).This was our only reason for overriding the template in the first place.
Based on variable names (not running or patching locally), these lines seem related to the bug: v7.4.5...v7.4.6#diff-b9feb1a9197bb7ede09e199a2f59dc83f40cc286ff87413496235df48bd05c5eL333-L336
Looks like github isn't the best at rendering which lines were highlighted in above link! They are sphinx/ext/autosummary/generate.py, Lins 333-336 (maybe linking in the commit is easier: e61f569#diff-b9feb1a9197bb7ede09e199a2f59dc83f40cc286ff87413496235df48bd05c5eL333-L477)
MetRonnie commentedon Aug 5, 2025
We are also seeing this warning in Sphinx 8.2.3, when trying to get rid of the warning from #12589
We have
with a template
{{ fullname | escape | underline }} .. automodule:: {{ fullname }} :members: {{ functions | join(', ') }} {% block functions %} Python API ---------- {% endblock %}I tried
However this results in
In addition to the original warning!
CAM-Gerlach commentedon Nov 29, 2025
We ran into the same error as in the OP breaking the build of the Spyder API docs when trying to customize the template to put the
modulesblock first, and can confirm we can repro it in Sphinx 8.2.3 (current stable as of this writing) with the default template by simply moving themodulesblock with theautosummarydirective to above theautomoduledirective.As it seems clearly desirable that a summary table of a module's immediate children belongs near the top where it is easily accessible rather than buried all the way at the bottom of the module's content (not sure why the default template has it seemingly backwards to begin with), this is a pretty important issue for us.
Given the error message doesn't appear to give much obvious insight on what's going on here, I'm not really sure where to start debugging this, but @AA-Turner if you are able to point me in the right direction, I might be able to take a crack at it.
AA-Turner commentedon Nov 29, 2025
Can you paste the full error with
--show-tracebackon Sphinx 9.0.0rc1?A
CAM-Gerlach commentedon Nov 29, 2025
@AA-Turner I had to do a bit of hackery to get Sphinx 9 to work with that project (as it is partially MyST-based, which doesn't officially support Sphinx 9 yet), but running 9.0.0rc1 with
--show-tracebackdoesn't apparently produce a traceback, just the same messages as before. I also tried with and without-W,-E,-a, and--keep-goingbut it made no different to showing the traceback, and confirmedautodoc_warningiserrorisTrue; I didn't see any other autodoc or autosummary settings that seemed relevant to not showing the traceback. Am I missing something here?Full output
AA-Turner commentedon Nov 29, 2025
Odd,. Try-Wshould raise an error.--exception-on-warninginstead.Can you try editing the file in your venv to insert a
raisehere?:sphinx/sphinx/ext/autosummary/__init__.py
Line 326 in cad3c43
A
CAM-Gerlach commentedon Nov 29, 2025
Yup, that was my next step looking for where to patch it. Here you go:
Full traceback
Full-er output
(Just for reference,
spyder-api-docshasspyderas a submodule, inside which there is a import package directoryspyder, theapisubpackage of which is (for now) the top-levelautosummary::target, which in turn contains the above-referenced moduleasyncdispatcher.)AA-Turner commentedon Nov 29, 2025
Can you paste the
.. autosummary::directive itself? It's trying (failing) to import a moduleasyncdispatcherwith no context as to the parent package, so clearly that's getting lost somewhere.Another thing to try is running with
--exception-on-warning -vv, though I don't know what (if anything) the extra verbosity will show.A
CAM-Gerlach commentedon Nov 29, 2025
Top-level
reference.rstcontaining the rootautosummarydirective:Autosummary directive in the template (only deltas from the default are moved above
automoduleand aded:template::Full template
{{ fullname | escape | underline}} {%- block modules %} {%- if modules %} .. rubric:: Modules .. autosummary:: :toctree: :template: custom-module-template.rst :recursive: {% for item in modules %} {{ item }} {%- endfor %} {% endif %} {%- endblock %} .. automodule:: {{ fullname }} {% block attributes %} {%- if attributes %} .. rubric:: {{ _('Module Attributes') }} .. autosummary:: {% for item in attributes %} {{ item }} {%- endfor %} {% endif %} {%- endblock %} {%- block functions %} {%- if functions %} .. rubric:: {{ _('Functions') }} .. autosummary:: {% for item in functions %} {{ item }} {%- endfor %} {% endif %} {%- endblock %} {%- block classes %} {%- if classes %} .. rubric:: {{ _('Classes') }} .. autosummary:: {% for item in classes %} {{ item }} {%- endfor %} {% endif %} {%- endblock %} {%- block exceptions %} {%- if exceptions %} .. rubric:: {{ _('Exceptions') }} .. autosummary:: {% for item in exceptions %} {{ item }} {%- endfor %} {% endif %} {%- endblock %}Running Sphinx with
--exception-on-warning -vv(keeping the patch from before) produced a bunch of informational output, but not much more in terms of details on the error:Traceback
Full console output
Just for reference, here's the output of a successful build with the
autosummaryblock moved back belowautomodule(with only one-v;-vvon a successful build fills my entire 32k line scrollback buffer and then some):Details
AA-Turner commentedon Nov 29, 2025
What's the content of
D:\Repos\Spyder\spyder-api-docs\docs\_autosummary\spyder.api.rst?CAM-Gerlach commentedon Nov 29, 2025
With
autosummaryaboveautomodulein the template (failed build, onlyspyder.api.rstgenerated):(only
spyder.api.rstis generated, no other files)With a
autosummarybelowautomodulein the template (successful build, all files generated):Abrosimov-a-a commentedon Nov 29, 2025
I encountered a similar error after updating to branch 8. The issue was resolved by modifying my custom template
module.rst.j2:.. autosummary:: :template: autosummary/module.rst.j2 :toctree: :recursive: {% for item in modules %} - {{ item }} + {{ fullname }}.{{ item }} {%- endfor %} {% endif %} {% endblock %}Hope this helps.
CAM-Gerlach commentedon Nov 29, 2025
Thanks, I can confirm that temporary workaround does get the build working again with the autosummary module ToC above the automodule section, although with the undesirable side effect of listing every submodule name in fully qualified form, with a redundant prefix of the current module. Hopefully it helps shed light on the root cause of the issue, where it seems autosummary doesn't know/prepend the current fully qualified module if run before
automodule, so it can actually be fixed.