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
+4 -2
View File
@@ -179,6 +179,7 @@ class GenerateBaseServing(BaseServing, BeamSearchOnlineMixin):
Args:
n: Number of sequences the request will occupy.
"""
if self.engine_client.errored:
raise self.engine_client.dead_error
@@ -236,7 +237,7 @@ class GenerateBaseServing(BaseServing, BeamSearchOnlineMixin):
@staticmethod
def _get_data_parallel_rank(raw_request: Request | None) -> int | None:
"""Pulls the data parallel rank from a header, if provided"""
"""Pulls the data parallel rank from a header, if provided."""
if raw_request is None:
return None
@@ -294,7 +295,8 @@ class GenerateBaseServing(BaseServing, BeamSearchOnlineMixin):
) -> _T:
"""Wrap a `create_*` coroutine so that, if it raises or returns an
ErrorResponse (i.e. the request never reached the engine), the KV
connector is notified to free any pinned remote-prefill blocks."""
connector is notified to free any pinned remote-prefill blocks.
"""
kv_transfer_params = self.has_kv_connector and request.kv_transfer_params
if not kv_transfer_params or not kv_transfer_params.get("do_remote_prefill"):
return await awaitable
@@ -53,7 +53,7 @@ def _bitmask_to_token_ids(bitmask_row: torch.Tensor, vocab_size: int) -> list[in
class BeamSearchOfflineMixin(OfflineInferenceMixin):
"""Offline inference for beam search"""
"""Offline inference for beam search."""
def beam_search(
self,
@@ -63,8 +63,7 @@ class BeamSearchOfflineMixin(OfflineInferenceMixin):
use_tqdm: bool = False,
concurrency_limit: int | None = None,
) -> list[BeamSearchOutput]:
"""
Generate sequences using beam search.
"""Generate sequences using beam search.
Args:
prompts: A list of prompts. Each prompt can be a string or a list
@@ -74,6 +73,7 @@ class BeamSearchOfflineMixin(OfflineInferenceMixin):
use_tqdm: Whether to use tqdm to display the progress bar.
concurrency_limit: The maximum number of concurrent requests.
If None, the number of concurrent requests is unlimited.
"""
# TODO: how does beam search work together with length penalty,
# frequency, penalty, and stopping criteria, etc.?
@@ -20,7 +20,7 @@ from .utils import BeamSearchSequence, create_sort_beams_key_function
class BeamSearchOnlineMixin(ABC):
"""online serving for beam search"""
"""online serving for beam search."""
renderer: BaseRenderer
engine_client: EngineClient
@@ -60,6 +60,7 @@ class GenerativeScoringRequest(OpenAIBaseModel):
the full vocab for those ids (False).
item_first: If True, prepend items to query. Otherwise append items to query.
add_special_tokens: Whether to add special tokens when tokenizing.
"""
model: str | None = None
@@ -112,6 +113,7 @@ class GenerativeScoringItemResult(OpenAIBaseModel):
index: The index of this item in the input items list.
object: Type of object, always "score".
score: The probability score for the first label token.
"""
index: int
@@ -129,6 +131,7 @@ class GenerativeScoringResponse(OpenAIBaseModel):
model: The model used for scoring.
data: List of scoring results, one per input item.
usage: Token usage information.
"""
id: str = Field(default="")
@@ -188,6 +191,7 @@ class ServingGenerativeScoring(BaseServing):
Returns:
GenerativeScoringResponse with probabilities for each item, or
ErrorResponse if an error occurred.
"""
# Check model
error_check_ret = await self._check_model(request) # type: ignore[arg-type]
@@ -401,6 +405,7 @@ class ServingGenerativeScoring(BaseServing):
Returns:
Tuple of (list of EngineInput, list of prompt token counts).
"""
# Tokenize query if it's a string
if isinstance(request.query, str):
@@ -455,6 +460,7 @@ class ServingGenerativeScoring(BaseServing):
Returns:
Dictionary mapping token_id to probability.
"""
if apply_softmax:
# Normalize over only the label tokens (subset softmax)