From f615ec6bc1270ed83bc697f4e0636938b6e1ffa0 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Wed, 3 Dec 2025 22:24:54 +0000 Subject: [PATCH] autodoc: Restore ``mock`` module for compatibility --- CHANGES.rst | 2 ++ sphinx/ext/autodoc/importer.py | 15 ++++++--------- sphinx/ext/autodoc/mock.py | 13 +++++++++++++ sphinx/ext/autodoc/preserve_defaults.py | 20 ++++++-------------- sphinx/ext/autodoc/type_comment.py | 8 ++------ 5 files changed, 29 insertions(+), 29 deletions(-) create mode 100644 sphinx/ext/autodoc/mock.py diff --git a/CHANGES.rst b/CHANGES.rst index 3ff5d7020f1..2273d7eba88 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,8 @@ Release 9.0.2 (in development) Bugs fixed ---------- +* #14142: autodoc: Restore :mod:`!sphinx.ext.autodoc.mock`. + Patch by Adam Turner. Release 9.0.1 (released Dec 01, 2025) ===================================== diff --git a/sphinx/ext/autodoc/importer.py b/sphinx/ext/autodoc/importer.py index 3af63ac81b7..02cf4d14f53 100644 --- a/sphinx/ext/autodoc/importer.py +++ b/sphinx/ext/autodoc/importer.py @@ -8,21 +8,18 @@ from sphinx.errors import PycodeError from sphinx.ext.autodoc._dynamic._importer import ( - _find_type_stub_spec as _find_type_stub_spec, # NoQA: PLC0414 + _find_type_stub_spec, # NoQA: F401 + _reload_module, # NoQA: F401 + _StubFileLoader, # NoQA: F401 ) from sphinx.ext.autodoc._dynamic._importer import ( _import_module as import_module, ) from sphinx.ext.autodoc._dynamic._importer import _mangle_name as mangle -from sphinx.ext.autodoc._dynamic._importer import ( - _reload_module as _reload_module, # NoQA: PLC0414 -) -from sphinx.ext.autodoc._dynamic._importer import ( - _StubFileLoader as _StubFileLoader, # NoQA: PLC0414 -) -from sphinx.ext.autodoc._dynamic._member_finder import _filter_enum_dict, unmangle from sphinx.ext.autodoc._dynamic._member_finder import ( - _is_native_enum_api as _is_native_enum_api, # NoQA: PLC0414 + _filter_enum_dict, + _is_native_enum_api, # NoQA: F401 + unmangle, ) from sphinx.ext.autodoc._dynamic._mock import ismock, undecorate from sphinx.ext.autodoc._shared import LOGGER diff --git a/sphinx/ext/autodoc/mock.py b/sphinx/ext/autodoc/mock.py new file mode 100644 index 00000000000..1fb4330bdfd --- /dev/null +++ b/sphinx/ext/autodoc/mock.py @@ -0,0 +1,13 @@ +from __future__ import annotations + +from sphinx.ext.autodoc._dynamic._mock import ( + MockFinder, # NoQA: F401 + MockLoader, # NoQA: F401 + _make_subclass, # NoQA: F401 + _MockModule, # NoQA: F401 + _MockObject, # NoQA: F401 + ismock, # NoQA: F401 + ismockmodule, # NoQA: F401 + mock, # NoQA: F401 + undecorate, # NoQA: F401 +) diff --git a/sphinx/ext/autodoc/preserve_defaults.py b/sphinx/ext/autodoc/preserve_defaults.py index d1ead6eeafd..fed033a7ec1 100644 --- a/sphinx/ext/autodoc/preserve_defaults.py +++ b/sphinx/ext/autodoc/preserve_defaults.py @@ -9,21 +9,13 @@ from typing import TYPE_CHECKING from sphinx.ext.autodoc._dynamic._preserve_defaults import ( - DefaultValue as DefaultValue, # NoQA: PLC0414 + DefaultValue, # NoQA: F401 + _get_arguments, # NoQA: F401 + _get_arguments_inner, # NoQA: F401 + _is_lambda, # NoQA: F401 + get_default_value, # NoQA: F401 + update_default_value, ) -from sphinx.ext.autodoc._dynamic._preserve_defaults import ( - _get_arguments as _get_arguments, # NoQA: PLC0414 -) -from sphinx.ext.autodoc._dynamic._preserve_defaults import ( - _get_arguments_inner as _get_arguments_inner, # NoQA: PLC0414 -) -from sphinx.ext.autodoc._dynamic._preserve_defaults import ( - _is_lambda as _is_lambda, # NoQA: PLC0414 -) -from sphinx.ext.autodoc._dynamic._preserve_defaults import ( - get_default_value as get_default_value, # NoQA: PLC0414 -) -from sphinx.ext.autodoc._dynamic._preserve_defaults import update_default_value if TYPE_CHECKING: from typing import Any diff --git a/sphinx/ext/autodoc/type_comment.py b/sphinx/ext/autodoc/type_comment.py index 3211213fd55..e099ca7b492 100644 --- a/sphinx/ext/autodoc/type_comment.py +++ b/sphinx/ext/autodoc/type_comment.py @@ -6,12 +6,8 @@ from sphinx.ext.autodoc._dynamic._type_comments import ( _update_annotations_using_type_comments, -) -from sphinx.ext.autodoc._dynamic._type_comments import ( - not_suppressed as not_suppressed, # NoQA: PLC0414 -) -from sphinx.ext.autodoc._dynamic._type_comments import ( - signature_from_ast as signature_from_ast, # NoQA: PLC0414 + not_suppressed, # NoQA: F401 + signature_from_ast, # NoQA: F401 ) if TYPE_CHECKING: