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
@@ -454,7 +454,8 @@ async def test_derender_completion_empty_generate_responses(client):
@pytest.mark.asyncio
async def test_derender_completion_logprobs(client):
"""token_id:N placeholders in logprobs are resolved; CompletionLogProbs
flat-list structure is returned with non-empty tokens and text_offsets."""
flat-list structure is returned with non-empty tokens and text_offsets.
"""
gr1 = await _render_completion(client, "Hello world")
ids1 = gr1["token_ids"][:3]
token_id = ids1[0]
@@ -555,7 +556,7 @@ async def test_derender_chat_oversized_token_ids_rejected(client):
@pytest.mark.asyncio
async def test_derender_chat_too_many_choices_rejected(client):
"""choices count exceeding VLLM_MAX_N_SEQUENCES returns 400."""
"""Choices count exceeding VLLM_MAX_N_SEQUENCES returns 400."""
# Default VLLM_MAX_N_SEQUENCES is 16384; use a larger count.
oversized_choices = [
{"index": i, "token_ids": [42], "finish_reason": "stop"} for i in range(20_000)
@@ -121,7 +121,8 @@ async def _disagg(
def _tool_sig(response_choice: dict) -> list[tuple[str, dict]]:
"""[(name, json normalized args)] so key ordering / whitespace don't
cause false negatives."""
cause false negatives.
"""
return [
(tc["function"]["name"], json.loads(tc["function"]["arguments"]))
for tc in (response_choice["message"].get("tool_calls") or [])
@@ -143,7 +144,8 @@ async def _run_parity_case(
client: httpx.AsyncClient, messages: list[dict], **extra
) -> tuple[dict, dict]:
"""Run the coupled request then feed its generated tokens into the
disaggregated derender endpoint. Returns (coupled, disagg)."""
disaggregated derender endpoint. Returns (coupled, disagg).
"""
coupled = await _coupled(client, messages, **extra)
ch = coupled["choices"][0]
chat_request = {"model": MODEL, "messages": messages, **extra}
@@ -203,7 +205,8 @@ async def test_parity_tool_call(client):
@pytest.mark.asyncio
async def test_parity_reasoning_and_tool_call(client):
"""Combined reasoning + tool call parity means the highest drift risk
since it exercises both parser branches on the same output."""
since it exercises both parser branches on the same output.
"""
messages = [{"role": "user", "content": "What's the weather in Paris?"}]
coupled, disagg = await _run_parity_case(
client,
@@ -41,7 +41,6 @@ def _make_stream_chunk(
usage: dict | None = None,
) -> GenerateStreamResponse:
"""Build a GenerateStreamResponse SSE chunk."""
return GenerateStreamResponse(
request_id=request_id,
choices=[
@@ -61,7 +60,6 @@ def _make_usage_chunk(
request_id: str = "test-req",
) -> GenerateStreamResponse:
"""Build a usage only final SSE chunk (empty choices)."""
return GenerateStreamResponse(
request_id=request_id,
choices=[],
@@ -531,7 +529,6 @@ async def client(server):
async def _render_chat(client) -> dict:
"""Render a minimal chat request and return the GenerateRequest dict."""
resp = await client.post(
"/v1/chat/completions/render",
json={
@@ -337,7 +337,6 @@ async def test_chat_completion_render_multi_turn(client):
@pytest.mark.asyncio
async def test_chat_completion_render_with_stream_true(client):
"""Render accepts stream params but still returns JSON (non-streamed)."""
response = await client.post(
"/v1/chat/completions/render",
json={
@@ -456,7 +455,8 @@ async def test_chat_completion_render_with_sampling_params(client):
@pytest.mark.asyncio
async def test_completion_render_emits_token_offsets(client):
"""With return_token_offsets, /v1/completions/render returns per-token
(start, end) char offsets aligned with token_ids."""
(start, end) char offsets aligned with token_ids.
"""
prompt = "Hello, world."
response = await client.post(
"/v1/completions/render",
@@ -481,7 +481,8 @@ async def test_completion_render_emits_token_offsets(client):
@pytest.mark.asyncio
async def test_completion_render_default_no_token_offsets(client):
"""Without the flag, token_offsets must be null (existing responses
unchanged)."""
unchanged).
"""
response = await client.post(
"/v1/completions/render",
json={
@@ -498,7 +499,8 @@ async def test_completion_render_default_no_token_offsets(client):
@pytest.mark.asyncio
async def test_chat_render_emits_token_offsets(client):
"""With return_token_offsets, /v1/chat/completions/render returns
per-token offsets relative to the templated prompt string."""
per-token offsets relative to the templated prompt string.
"""
response = await client.post(
"/v1/chat/completions/render",
json={
@@ -672,7 +674,8 @@ async def test_chat_completion_render_assistant_tokens_mask_with_generation_tags
client,
):
"""With a ``{% generation %}``-enabled template, the mask marks assistant
tokens and the masked tokens decode to the assistant content."""
tokens and the masked tokens decode to the assistant content.
"""
response = await client.post(
"/v1/chat/completions/render",
json={
@@ -16,7 +16,6 @@ VISION_MODEL_NAME = "Qwen/Qwen3-VL-2B-Instruct"
@pytest.fixture(scope="module")
def vision_server():
"""Vision-capable server used for multimodal /render tests."""
args = [
"--enforce-eager",
"--max-model-len",
@@ -48,7 +47,6 @@ async def test_chat_completion_render_with_base64_image_url(
local_asset_server,
):
"""Render a multimodal chat request and verify tokens are returned."""
image = local_asset_server.get_image_asset("RGBA_comp.png")
data_url = encode_image_url(image, format="PNG")
@@ -112,7 +110,6 @@ async def test_tokenize_matches_render_for_multimodal_input(
local_asset_server,
):
"""`/tokenize` should match `/v1/chat/completions/render` token output."""
image = local_asset_server.get_image_asset("RGBA_comp.png")
data_url = encode_image_url(image, format="PNG")
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""
Roundtrip tests for multimodal serde used by the
"""Roundtrip tests for multimodal serde used by the
token_in_token_out generate endpoint.
"""
@@ -25,7 +25,8 @@ def _base_payload() -> dict:
def test_omitted_max_tokens_is_not_provided():
"""Body without ``max_tokens`` must surface as 'not provided' so the
server can apply its own default instead of the dataclass 16."""
server can apply its own default instead of the dataclass 16.
"""
req = GenerateRequest.model_validate(_base_payload())
# SamplingParams' dataclass default leaks through the parsed instance —
# this is exactly the bug the server-side defaulting works around.
@@ -35,7 +36,8 @@ def test_omitted_max_tokens_is_not_provided():
def test_explicit_max_tokens_is_provided():
"""Even when the client picks the same value as the dataclass default,
it must register as explicitly set so the server won't override it."""
it must register as explicitly set so the server won't override it.
"""
payload = _base_payload()
payload["sampling_params"] = {"max_tokens": 16}
req = GenerateRequest.model_validate(payload)
@@ -67,7 +69,8 @@ def test_json_roundtrip_preserves_provided_keys():
def test_internal_instance_construction_treats_all_as_provided():
"""When internal callers build ``GenerateRequest`` from a pre-resolved
``SamplingParams`` instance, every field is considered explicitly set
so server-side defaulting can't clobber values resolved upstream."""
so server-side defaulting can't clobber values resolved upstream.
"""
sp = SamplingParams(max_tokens=500, temperature=0.0)
req = GenerateRequest(token_ids=[1, 2, 3], sampling_params=sp)
assert req.is_sampling_param_provided("max_tokens")