[CI] Fix docs build (#52937)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>

Harry Mellor committed Aug 19, 2026 at 13:25 UTC 2f54100a593e34dd473912c756346abee55a6246
2 files changed +28 -18
docs/mkdocs/gen_files/generate_argparse.py
+27 -17
@@ -27,16 +27,30 @@ sys.path.insert(0, str(Path(__file__).parent))
27
28 from generated_content import fill_markers # noqa: E402
29
30 +HAS_TORCH = importlib.util.find_spec("torch") is not None
31 +
32
33 def mock_if_no_torch(mock_module: str, mock: MagicMock):
32 - if not importlib.util.find_spec("torch"):
34 + if not HAS_TORCH:
35 sys.modules[mock_module] = mock
36
37
38 +class PydanticMagicMock(MagicMock):
39 + """`MagicMock` that's able to generate pydantic-core schemas."""
40 +
41 + def __init__(self, *args, **kwargs):
42 + name = kwargs.get("name")
43 + super().__init__(*args, **kwargs)
44 + self.__spec__ = ModuleSpec(name, None)
45 +
46 + def __get_pydantic_core_schema__(self, source_type, handler):
47 + return core_schema.any_schema()
48 +
49 +
50 # Mock custom op code
51 class MockCustomOp:
52 @staticmethod
39 - def register(name):
53 + def register(*args, **kwargs):
54 def decorator(cls):
55 return cls
56
@@ -45,7 +59,7 @@ class MockCustomOp:
59
60 class MockPluggableLayer:
61 @staticmethod
48 - def register(name):
62 + def register(*args, **kwargs):
63 def decorator(cls):
64 return cls
65
@@ -69,8 +83,16 @@ with open(ROOT_DIR / "requirements/test/cuda.txt") as f:
83 importlib.metadata.version = lambda name: VERSIONS.get(name) or "0.0.0"
84
85
72 -# Make torch.nn.Parameter safe to inherit from
73 -mock_if_no_torch("torch.nn", MagicMock(Parameter=object))
86 +# Real class because a `MagicMock` base conflicts with `ABCMeta`
87 +class MockModule:
88 + pass
89 +
90 +
91 +# Make torch.nn.Parameter and torch.nn.Module safe to inherit from.
92 +# `import torch.nn` resolves the attribute on `torch`, so mock both.
93 +mock_nn = MagicMock(Parameter=object, Module=MockModule)
94 +mock_if_no_torch("torch.nn", mock_nn)
95 +mock_if_no_torch("torch", PydanticMagicMock(name="torch", nn=mock_nn))
96
97
98 # Mock torch.library.infer_schema for vllm.ir.ops.IrOpInplaceOverload.__init__
@@ -98,18 +120,6 @@ mock_if_no_torch(
120 )
121
122
101 -class PydanticMagicMock(MagicMock):
102 - """`MagicMock` that's able to generate pydantic-core schemas."""
103 -
104 - def __init__(self, *args, **kwargs):
105 - name = kwargs.get("name")
106 - super().__init__(*args, **kwargs)
107 - self.__spec__ = ModuleSpec(name, None)
108 -
109 - def __get_pydantic_core_schema__(self, source_type, handler):
110 - return core_schema.any_schema()
111 -
112 -
123 def auto_mock(module_name: str, attr: str, max_mocks: int = 100):
124 """Function that automatically mocks missing modules during imports."""
125 logger.info("Importing %s from %s", attr, module_name)
vllm/multimodal/video.py
+1 -1
@@ -220,7 +220,7 @@ class VideoBackend(VideoLoader):
220 frame_recovery: bool = False,
221 *,
222 backend: VideoDecoderBackend = "opencv",
223 - **kwargs,
223 + **kwargs: Any,
224 ) -> tuple[npt.NDArray, dict[str, Any]]:
225 """Load sampled frames from raw video bytes.
226