From 05a14ff007038c45336d18b137718c6eab16f9cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=A9o=20Bouvard?= Date: Fri, 28 Jul 2023 18:53:49 +0200 Subject: [PATCH] Don't filter ``ImportWarning`` in ``ext.autodoc.importer`` (#11024) --- sphinx/ext/autodoc/importer.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sphinx/ext/autodoc/importer.py b/sphinx/ext/autodoc/importer.py index c8ddf33c2..2082a7140 100644 --- a/sphinx/ext/autodoc/importer.py +++ b/sphinx/ext/autodoc/importer.py @@ -5,7 +5,6 @@ from __future__ import annotations import importlib import traceback import typing -import warnings from typing import TYPE_CHECKING, Any, Callable, NamedTuple 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 """ 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.