mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Don't filter `ImportWarning
in
ext.autodoc.importer
` (#11024)
This commit is contained in:
parent
eb3fffc3e9
commit
05a14ff007
@ -5,7 +5,6 @@ from __future__ import annotations
|
|||||||
import importlib
|
import importlib
|
||||||
import traceback
|
import traceback
|
||||||
import typing
|
import typing
|
||||||
import warnings
|
|
||||||
from typing import TYPE_CHECKING, Any, Callable, NamedTuple
|
from typing import TYPE_CHECKING, Any, Callable, NamedTuple
|
||||||
|
|
||||||
from sphinx.ext.autodoc.mock import ismock, undecorate
|
from sphinx.ext.autodoc.mock import ismock, undecorate
|
||||||
@ -61,10 +60,8 @@ def import_module(modname: str, warningiserror: bool = False) -> Any:
|
|||||||
Call importlib.import_module(modname), convert exceptions to ImportError
|
Call importlib.import_module(modname), convert exceptions to ImportError
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
with warnings.catch_warnings():
|
with logging.skip_warningiserror(not warningiserror):
|
||||||
warnings.filterwarnings("ignore", category=ImportWarning)
|
return importlib.import_module(modname)
|
||||||
with logging.skip_warningiserror(not warningiserror):
|
|
||||||
return importlib.import_module(modname)
|
|
||||||
except BaseException as exc:
|
except BaseException as exc:
|
||||||
# Importing modules may cause any side effects, including
|
# Importing modules may cause any side effects, including
|
||||||
# SystemExit, so we need to catch all errors.
|
# SystemExit, so we need to catch all errors.
|
||||||
|
Loading…
Reference in New Issue
Block a user