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
+8 -9
View File
@@ -37,7 +37,7 @@ logger = init_logger(__name__)
class PoolingOfflineMixin(OfflineInferenceMixin):
"""Offline inference for pooling models"""
"""Offline inference for pooling models."""
runner_type: str
chat_template: str | None
@@ -93,8 +93,8 @@ class PoolingOfflineMixin(OfflineInferenceMixin):
Returns:
A list of `PoolingRequestOutput` objects containing the
pooled hidden states in the same order as the input prompts.
"""
"""
if isinstance(prompts, dict) and "data" in prompts and pooling_task != "plugin":
raise ValueError(
"The 'data' field is only supported for the 'plugin' pooling task."
@@ -203,8 +203,7 @@ class PoolingOfflineMixin(OfflineInferenceMixin):
lora_request: list[LoRARequest] | LoRARequest | None = None,
tokenization_kwargs: dict[str, Any] | None = None,
) -> list[EmbeddingRequestOutput]:
"""
Generate an embedding vector for each prompt.
"""Generate an embedding vector for each prompt.
This class automatically batches the given prompts, considering
the memory constraint. For the best performance, put all of your prompts
@@ -226,8 +225,8 @@ class PoolingOfflineMixin(OfflineInferenceMixin):
Returns:
A list of `EmbeddingRequestOutput` objects containing the
embedding vectors in the same order as the input prompts.
"""
"""
items = self.encode(
prompts,
use_tqdm=use_tqdm,
@@ -248,8 +247,7 @@ class PoolingOfflineMixin(OfflineInferenceMixin):
lora_request: list[LoRARequest] | LoRARequest | None = None,
tokenization_kwargs: dict[str, Any] | None = None,
) -> list[ClassificationRequestOutput]:
"""
Generate class logits for each prompt.
"""Generate class logits for each prompt.
This class automatically batches the given prompts, considering
the memory constraint. For the best performance, put all of your prompts
@@ -271,8 +269,8 @@ class PoolingOfflineMixin(OfflineInferenceMixin):
Returns:
A list of `ClassificationRequestOutput` objects containing the
embedding vectors in the same order as the input prompts.
"""
"""
items = self.encode(
prompts,
use_tqdm=use_tqdm,
@@ -330,11 +328,12 @@ class PoolingOfflineMixin(OfflineInferenceMixin):
chat_template: The chat template to use for the scoring. If None, we
use the model's default chat template.
tokenization_kwargs: Overrides for `tokenizer.encode`.
Returns:
A list of `ScoringRequestOutput` objects containing the
generated scores in the same order as the input prompts.
"""
"""
if self.runner_type != "pooling":
raise ValueError(
"LLM.score() is only supported for pooling models. "
@@ -44,7 +44,8 @@ class PluginWithoutIOProcessorPlugins(PoolingIOProcessor):
class PluginWithIOProcessorPlugins(PoolingIOProcessor):
"""IO Processor plugins are a feature that allows pre- and post-processing
of the model input and output for pooling models."""
of the model input and output for pooling models.
"""
name = "plugin"
+1 -2
View File
@@ -21,8 +21,7 @@ ScoreContentPartParam: TypeAlias = (
class ScoreMultiModalParam(TypedDict, total=False):
"""
A specialized parameter type for scoring multimodal content
"""A specialized parameter type for scoring multimodal content.
The reasons why don't reuse `CustomChatCompletionMessageParam` directly:
1. Score tasks don't need the 'role' field (user/assistant/system) that's required in chat completions
+3 -4
View File
@@ -58,8 +58,7 @@ def truncate_text_to_tokens(
def compute_maxsim_score(q_emb: torch.Tensor, d_emb: torch.Tensor) -> torch.Tensor:
"""
Compute ColBERT MaxSim score.
"""Compute ColBERT MaxSim score.
Args:
q_emb: Query token embeddings [query_len, dim]
@@ -67,6 +66,7 @@ def compute_maxsim_score(q_emb: torch.Tensor, d_emb: torch.Tensor) -> torch.Tens
Returns:
MaxSim score (sum over query tokens of max similarity to any doc token)
"""
# compute in float32 for numerical stability
# [query_len, doc_len]
@@ -249,8 +249,7 @@ def parse_score_data(
def compress_token_type_ids(token_type_ids: list[int]) -> int:
"""
Return position of the first 1 or the length of the list
"""Return position of the first 1 or the length of the list
if not found.
"""
first_one = len(token_type_ids)