Skip to content

Commit

Permalink
Don't filter ImportWarning in ext.autodoc.importer (#11024)
Browse files Browse the repository at this point in the history
  • Loading branch information
teobouvard committed Jul 28, 2023
1 parent eb3fffc commit 05a14ff
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions sphinx/ext/autodoc/importer.py
Expand Up @@ -5,7 +5,6 @@
import importlib
import traceback
import typing
import warnings
from typing import TYPE_CHECKING, Any, Callable, NamedTuple

from sphinx.ext.autodoc.mock import ismock, undecorate
Expand Down Expand Up @@ -61,10 +60,8 @@ def import_module(modname: str, warningiserror: bool = False) -> Any:
Call importlib.import_module(modname), convert exceptions to ImportError
"""
try:
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=ImportWarning)
with logging.skip_warningiserror(not warningiserror):
return importlib.import_module(modname)
with logging.skip_warningiserror(not warningiserror):
return importlib.import_module(modname)
except BaseException as exc:
# Importing modules may cause any side effects, including
# SystemExit, so we need to catch all errors.
Expand Down

0 comments on commit 05a14ff

Please sign in to comment.