[Bugfix][Docs] Fix ReadTheDocs build crash from mocked torch decorator (#39284)

Signed-off-by: khluu <khluu000@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kevin H. Luu
2026-04-08 09:43:01 +00:00
committed by GitHub
co-authored by Claude Opus 4.6
parent 78434b923c
commit 6155bbd1dd
+3 -2
View File
@@ -59,7 +59,7 @@ class PydanticMagicMock(MagicMock):
"""`MagicMock` that's able to generate pydantic-core schemas."""
def __init__(self, *args, **kwargs):
name = kwargs.pop("name", None)
name = kwargs.get("name")
super().__init__(*args, **kwargs)
self.__spec__ = ModuleSpec(name, None)
@@ -85,7 +85,8 @@ def auto_mock(module_name: str, attr: str, max_mocks: int = 100):
logger.info("Mocking %s for argparse doc generation", e.name)
sys.modules[e.name] = PydanticMagicMock(name=e.name)
except Exception:
logger.exception("Failed to import %s.%s: %s", module_name, attr)
logger.exception("Failed to import %s.%s", module_name, attr)
raise
raise ImportError(
f"Failed to import {module_name}.{attr} after mocking {max_mocks} imports"