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
+12 -6
View File
@@ -13,7 +13,8 @@ from vllm.benchmarks.datasets import BFCLDataset, get_samples
def _patch_hf_api(side_effect):
"""Return a patch context that swaps `hf_api()` to a stub whose
`.hf_hub_download` attribute uses `side_effect`."""
`.hf_hub_download` attribute uses `side_effect`.
"""
fake_api = MagicMock()
fake_api.hf_hub_download.side_effect = side_effect
return patch("vllm.benchmarks.datasets.datasets.hf_api", return_value=fake_api)
@@ -115,7 +116,8 @@ def test_bfcl_dataset_translates_schema_and_attaches_tools(
) -> None:
"""BFCLDataset should translate schemas to OpenAI tool format, set
`messages` directly on SampleRequest, and attach tools/tool_choice via
request_overrides."""
request_overrides.
"""
paths = _write_fake_files(tmp_path)
def fake_download(_repo, filename, **_kwargs):
@@ -166,7 +168,8 @@ def test_bfcl_dataset_missing_category_raises_clear_error(
hf_tokenizer: PreTrainedTokenizerBase,
) -> None:
"""A typo'd category should produce an actionable ValueError, not an
opaque huggingface_hub exception."""
opaque huggingface_hub exception.
"""
from huggingface_hub.errors import EntryNotFoundError
args = _args_for_bfcl(categories=["simpl"]) # typo
@@ -184,7 +187,8 @@ def test_bfcl_dataset_missing_category_raises_clear_error(
@pytest.mark.benchmark
def test_chat_backend_uses_messages_field_when_set() -> None:
"""When RequestFuncInput.chat_messages is set, the chat backend must use
it verbatim and skip default content construction from `prompt`."""
it verbatim and skip default content construction from `prompt`.
"""
import asyncio
from vllm.benchmarks.lib.endpoint_request_func import (
@@ -244,7 +248,8 @@ def test_chat_backend_uses_messages_field_when_set() -> None:
def test_bfcl_prompt_len_includes_tools(tmp_path: Path) -> None:
"""prompt_len must reflect tokens from both messages *and* tool schemas,
so percentile buckets and input-distribution summaries aren't biased
low for tool-heavy traffic."""
low for tool-heavy traffic.
"""
paths = _write_fake_files(tmp_path)
def fake_download(_repo, filename, **_kwargs):
@@ -291,7 +296,8 @@ def test_bfcl_prompt_len_falls_back_when_tokenizer_rejects_tools(
tmp_path: Path,
) -> None:
"""Older tokenizers don't accept tools=; fallback must still produce a
non-zero prompt_len without crashing."""
non-zero prompt_len without crashing.
"""
paths = _write_fake_files(tmp_path)
def fake_download(_repo, filename, **_kwargs):
@@ -12,7 +12,8 @@ from vllm.benchmarks.datasets import get_samples
class _RecordingTokenizer:
"""Minimal tokenizer stub that records the kwargs forwarded to
apply_chat_template, so we can assert chat_template_kwargs propagation
without loading a real model/template."""
without loading a real model/template.
"""
def __init__(self) -> None:
self.captured_kwargs: dict | None = None
@@ -228,7 +228,7 @@ def test_decode_span_identity_is_exact(
api_url: str,
chat: bool,
) -> None:
"""latency - ttft must equal sum(itl) exactly.
"""Latency - ttft must equal sum(itl) exactly.
On a scripted clock this can only drift if a code path reads the clock an
extra time or attributes a read to the wrong event.
+6 -3
View File
@@ -10,7 +10,8 @@ from vllm.tokenizers import TokenizerLike
class _FakeTokenizer(TokenizerLike):
"""Minimal tokenizer implementing the TokenizerLike protocol
for testing get_sampling_params."""
for testing get_sampling_params.
"""
def __init__(self, vocab_size: int = 1000, num_special_tokens: int = 0) -> None:
self._vocab_size = vocab_size
@@ -171,7 +172,8 @@ class TestGetSamplingParams:
def test_output_low_clamped_to_one(self):
"""Even with a high ratio that would push output_low to 0,
the function clamps it to 1."""
the function clamps it to 1.
"""
rng = np.random.default_rng(0)
# output_len=1, ratio=0.99 → floor(1*0.01)=0, should clamp to 1
_, output_lens, _ = get_sampling_params(
@@ -233,7 +235,8 @@ class TestGetSamplingParams:
def test_input_len_zero_with_special_tokens(self):
"""input_len < num_special_tokens → real_input_len = 0, which is fine
(range [0, 0])."""
(range [0, 0]).
"""
rng = np.random.default_rng(0)
input_lens, _, _ = get_sampling_params(
rng, 5, 0.0, 5, 50, self._tok(num_special=10)
+2 -1
View File
@@ -52,7 +52,8 @@ def _write_dataset(path: Path) -> None:
def _args(dataset_path: str) -> argparse.Namespace:
"""Reproduce the argparse.Namespace that serve.py builds from the
failing command, including skip_tokenizer_init=True."""
failing command, including skip_tokenizer_init=True.
"""
return argparse.Namespace(
# dataset
dataset_name="custom",