Unverified Commit 6155bbd1 authored by Kevin H. Luu's avatar Kevin H. Luu Committed by GitHub
Browse files

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


Signed-off-by: default avatarkhluu <khluu000@gmail.com>
Co-authored-by: default avatarClaude Opus 4.6 (1M context) <noreply@anthropic.com>
parent 78434b92
...@@ -59,7 +59,7 @@ class PydanticMagicMock(MagicMock): ...@@ -59,7 +59,7 @@ class PydanticMagicMock(MagicMock):
"""`MagicMock` that's able to generate pydantic-core schemas.""" """`MagicMock` that's able to generate pydantic-core schemas."""
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
name = kwargs.pop("name", None) name = kwargs.get("name")
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.__spec__ = ModuleSpec(name, None) self.__spec__ = ModuleSpec(name, None)
...@@ -85,7 +85,8 @@ def auto_mock(module_name: str, attr: str, max_mocks: int = 100): ...@@ -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) logger.info("Mocking %s for argparse doc generation", e.name)
sys.modules[e.name] = PydanticMagicMock(name=e.name) sys.modules[e.name] = PydanticMagicMock(name=e.name)
except Exception: 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( raise ImportError(
f"Failed to import {module_name}.{attr} after mocking {max_mocks} imports" f"Failed to import {module_name}.{attr} after mocking {max_mocks} imports"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment