-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Is your feature request related to a problem? Please describe.
The ImportExceptionGroup message can be very misleading:
no module named mymodule
is also displayed when mymodule is definitely a module, but there was e.g. some dependency import error.
And then you don’t even get to know what actual errors happened, since the sub-exceptions aren’t visible!
Describe the solution you'd like
Make sphinx.ext.autosummary.ImportExceptionGroup inherit from ExceptionGroup when possible:
if sys.version_info > (3, 11):
class ImportExceptionGroup(ExceptionGroup):
"""Exceptions raised during importing the target objects.
It contains an error messages and a list of exceptions as its arguments.
"""
else:
... # existing codethey share the same API and this will result in all sub-exceptions being displayed.
Also change the error message:
-raise ImportExceptionGroup('no module named %s' % ' or '.join(tried), exceptions)
+raise ImportExceptionGroup('could not import {"or ".join(tried)}', exceptions)Describe alternatives you've considered
N/A
Additional context
sphinx/sphinx/ext/autosummary/__init__.py
Line 613 in 62619bd
| class ImportExceptionGroup(Exception): |
sphinx/sphinx/ext/autosummary/__init__.py
Line 687 in 62619bd
| raise ImportExceptionGroup('no module named %s' % ' or '.join(tried), exceptions) |