Add pydocstyle to the ruff rules (#52136)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <hej.mellor@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Harry Mellor
2026-09-16 16:44:29 +00:00
committed by GitHub
co-authored by Claude Opus 5
parent 804e5377aa
commit 8c1557a79c
2002 changed files with 15024 additions and 14269 deletions
+22 -28
View File
@@ -58,8 +58,7 @@ else:
class ModalityDataItems(ABC, Generic[_T, _I]):
"""
Represents data items for a modality in
"""Represents data items for a modality in
[`MultiModalDataItems`][vllm.multimodal.parse.MultiModalDataItems].
"""
@@ -151,6 +150,7 @@ def validate_embedding_ndim(
tensor: The tensor to validate.
modality: The modality name for error messages (e.g., "image", "audio").
index: Optional index for list items, included in error messages.
"""
if tensor.ndim < 2 or tensor.ndim > 3:
idx_str = f" [{index}]" if index is not None else ""
@@ -164,8 +164,7 @@ def validate_embedding_ndim(
class EmbeddingItems(
ModalityDataItems[torch.Tensor | list[torch.Tensor], torch.Tensor]
):
"""
Base class for data items that are expressed as a batched embedding tensor,
"""Base class for data items that are expressed as a batched embedding tensor,
or a list of embedding tensors (one per item).
"""
@@ -251,8 +250,7 @@ class EmbeddingItems(
class DictEmbeddingItems(
ModalityDataItems[Mapping[str, torch.Tensor], Mapping[str, torch.Tensor]]
):
"""
Base class for data items that are expressed as a dictionary of tensors.
"""Base class for data items that are expressed as a dictionary of tensors.
Usually, the dictionary keys correspond to the outputs of HF processor.
"""
@@ -268,18 +266,18 @@ class DictEmbeddingItems(
],
optional_fields: Set[str] = frozenset(),
) -> None:
"""
Args:
data: The dictionary of tensors for this modality.
modality: The modality these items belong to.
required_fields: Fields `data` must contain.
fields_factory: Builds the field config from the data.
optional_fields: Fields `data` may omit. Which fields these are is
the caller's decision -- see
`MultiModalDataParser.embedding_field_sets`, where a deployment
that receives embeddings through an EC connector makes the
embeddings optional. They still need a field config, since they
are used whenever they *are* supplied.
"""Args:
data: The dictionary of tensors for this modality.
modality: The modality these items belong to.
required_fields: Fields `data` must contain.
fields_factory: Builds the field config from the data.
optional_fields: Fields `data` may omit. Which fields these are is
the caller's decision -- see
`MultiModalDataParser.embedding_field_sets`, where a deployment
that receives embeddings through an EC connector makes the
embeddings optional. They still need a field config, since they
are used whenever they *are* supplied.
"""
from transformers.feature_extraction_utils import BatchFeature
@@ -471,14 +469,12 @@ _D = TypeVar("_D", bound=ModalityDataItems[Any, Any])
class MultiModalDataItems(UserDict[str, ModalityDataItems[Any, Any]]):
"""
A normalized [`MultiModalDataDict`][vllm.inputs.MultiModalDataDict]
"""A normalized [`MultiModalDataDict`][vllm.inputs.MultiModalDataDict]
such that each entry corresponds to a list.
"""
def select(self, modalities: Set[str]):
"""
Construct a new `MultiModalDataItems` instance containing only the
"""Construct a new `MultiModalDataItems` instance containing only the
selected modalities.
"""
return MultiModalDataItems(
@@ -486,8 +482,7 @@ class MultiModalDataItems(UserDict[str, ModalityDataItems[Any, Any]]):
)
def get_count(self, modality: str, *, strict: bool = True) -> int:
"""
Get the number of data items belonging to a modality.
"""Get the number of data items belonging to a modality.
If `strict=False`, return `0` instead of raising [`KeyError`][]
even if the modality is not found.
@@ -513,8 +508,7 @@ class MultiModalDataItems(UserDict[str, ModalityDataItems[Any, Any]]):
modality: str,
typ: type[_D] | tuple[type[_D], ...],
) -> _D:
"""
Get the data items belonging to a modality,
"""Get the data items belonging to a modality,
requiring that they belong to a certain type.
"""
if modality not in self:
@@ -541,8 +535,7 @@ ModalityDataParser: TypeAlias = Callable[
class MultiModalDataParser:
"""
Parses [`MultiModalDataDict`][vllm.inputs.MultiModalDataDict]
"""Parses [`MultiModalDataDict`][vllm.inputs.MultiModalDataDict]
into [`MultiModalDataItems`][vllm.multimodal.parse.MultiModalDataItems].
Args:
@@ -561,6 +554,7 @@ class MultiModalDataParser:
allow_missing_mm_embeddings (bool): Whether pre-computed embedding
tensors may be absent from the request on a disaggregated consumer.
Derived by `BaseProcessingInfo.allow_missing_mm_embeddings`.
"""
embedding_fields: Mapping[str, Mapping[str, EmbeddingFieldRole]] = {}