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
@@ -81,7 +81,7 @@ def _new_online_renderer() -> OnlineRenderer:
class MockConversationContext(ConversationContext):
"""Mock conversation context for testing"""
"""Mock conversation context for testing."""
def __init__(self):
self.init_tool_sessions_called = False
@@ -123,7 +123,7 @@ def test_serialize_message_pydantic_model_returns_dict() -> None:
@pytest.fixture
def mock_serving_responses():
"""Create a mock OpenAIServingResponses instance"""
"""Create a mock OpenAIServingResponses instance."""
serving_responses = MagicMock(spec=OpenAIServingResponses)
serving_responses.tool_server = MagicMock(spec=ToolServer)
return serving_responses
@@ -131,13 +131,13 @@ def mock_serving_responses():
@pytest.fixture
def mock_context():
"""Create a mock conversation context"""
"""Create a mock conversation context."""
return MockConversationContext()
@pytest.fixture
def mock_exit_stack():
"""Create a mock async exit stack"""
"""Create a mock async exit stack."""
return MagicMock(spec=AsyncExitStack)
@@ -550,7 +550,7 @@ def test_responses_render_result_rejects_non_single_prompt(engine_inputs):
class TestInitializeToolSessions:
"""Test class for _initialize_tool_sessions method"""
"""Test class for _initialize_tool_sessions method."""
@pytest.fixture(params=[ParsableContext, HarmonyContext])
def tool_context(self, request):
@@ -635,7 +635,7 @@ class TestInitializeToolSessions:
@pytest_asyncio.fixture
async def serving_responses_instance(self):
"""Create a real OpenAIServingResponses instance for testing"""
"""Create a real OpenAIServingResponses instance for testing."""
# Create minimal mocks for required dependencies
engine_client = MagicMock()
@@ -802,8 +802,7 @@ class TestInitializeToolSessions:
async def test_initialize_tool_sessions(
self, serving_responses_instance, mock_context, mock_exit_stack
):
"""Test that method works correctly with only MCP tools"""
"""Test that method works correctly with only MCP tools."""
request = ResponsesRequest(input="test input", tools=[])
# Call the method
@@ -852,11 +851,11 @@ class TestInitializeToolSessions:
class TestValidateGeneratorInput:
"""Test class for _validate_generator_input method"""
"""Test class for _validate_generator_input method."""
@pytest_asyncio.fixture
async def serving_responses_instance(self):
"""Create a real OpenAIServingResponses instance for testing"""
"""Create a real OpenAIServingResponses instance for testing."""
# Create minimal mocks for required dependencies
engine_client = MagicMock()
@@ -884,7 +883,7 @@ class TestValidateGeneratorInput:
return instance
def test_validate_generator_input(self, serving_responses_instance):
"""Test _validate_generator_input with valid prompt length"""
"""Test _validate_generator_input with valid prompt length."""
# Create an engine prompt with valid length (less than max_model_len)
valid_prompt_token_ids = list(range(5)) # 5 tokens < 100 max_model_len
engine_input = tokens_input(valid_prompt_token_ids)
@@ -999,7 +998,7 @@ async def test_reasoning_tokens_counted_for_text_reasoning_model(monkeypatch):
class TestExtractAllowedToolsFromMcpRequests:
"""Test class for _extract_allowed_tools_from_mcp_requests function"""
"""Test class for _extract_allowed_tools_from_mcp_requests function."""
def test_extract_allowed_tools_basic_formats(self):
"""Test extraction with list format, object format, and None."""
@@ -1113,7 +1112,7 @@ class TestHarmonyPreambleStreaming:
return item
def test_preamble_delta_emits_text_events(self) -> None:
"""commentary + recipient=None should emit output_text.delta events."""
"""Commentary + recipient=None should emit output_text.delta events."""
from vllm.entrypoints.openai.responses.streaming_events import (
emit_content_delta_events,
)
@@ -1146,7 +1145,7 @@ class TestHarmonyPreambleStreaming:
assert "response.output_item.added" not in type_names
def test_commentary_with_function_recipient_not_preamble(self) -> None:
"""commentary + recipient='functions.X' must NOT use preamble path."""
"""Commentary + recipient='functions.X' must NOT use preamble path."""
from vllm.entrypoints.openai.responses.streaming_events import (
emit_content_delta_events,
)
@@ -1164,7 +1163,8 @@ class TestHarmonyPreambleStreaming:
def test_preamble_done_emits_text_done_events(self) -> None:
"""Completed preamble should emit text done + content_part done +
output_item done, same shape as final channel."""
output_item done, same shape as final channel.
"""
from vllm.entrypoints.openai.responses.streaming_events import (
emit_previous_item_done_events,
)
@@ -1184,8 +1184,9 @@ class TestHarmonyPreambleStreaming:
assert "response.output_item.done" in type_names
def test_commentary_with_recipient_no_preamble_done(self) -> None:
"""commentary + recipient='functions.X' should route to function call
done, not preamble done."""
"""Commentary + recipient='functions.X' should route to function call
done, not preamble done.
"""
from vllm.entrypoints.openai.responses.streaming_events import (
emit_previous_item_done_events,
)
@@ -1331,7 +1332,8 @@ def _mock_parser_with_reasoning(serving, delta_sequence: list[DeltaMessage]):
class TestStreamingReasoningToContentTransition:
"""Tests for _process_simple_streaming_events reasoning-to-content
transition, specifically the fix for mixed deltas that carry both
reasoning and content simultaneously."""
reasoning and content simultaneously.
"""
@pytest.mark.asyncio
async def test_mixed_delta_reasoning_and_content_emits_reasoning_delta(
@@ -1341,8 +1343,8 @@ class TestStreamingReasoningToContentTransition:
and content set (e.g. reasoning end and content start in the same
chunk), the trailing reasoning text must be emitted as a
ResponseReasoningTextDeltaEvent and included in the
ResponseReasoningTextDoneEvent text."""
ResponseReasoningTextDoneEvent text.
"""
monkeypatch.setattr(envs, "VLLM_USE_EXPERIMENTAL_PARSER_CONTEXT", False)
serving = _make_serving_instance_with_reasoning()
@@ -1411,8 +1413,8 @@ class TestStreamingReasoningToContentTransition:
self, monkeypatch
):
"""When the transition from reasoning to content is clean (no mixed
delta), no extra reasoning delta event should be emitted."""
delta), no extra reasoning delta event should be emitted.
"""
monkeypatch.setattr(envs, "VLLM_USE_EXPERIMENTAL_PARSER_CONTEXT", False)
serving = _make_serving_instance_with_reasoning()
@@ -1473,8 +1475,8 @@ class TestStreamingReasoningToContentTransition:
async def test_reasoning_only_stream_no_content(self, monkeypatch):
"""When the stream has only reasoning deltas and no content, the
reasoning done event should be emitted at finalization with the
full accumulated text, and no text delta events should appear."""
full accumulated text, and no text delta events should appear.
"""
monkeypatch.setattr(envs, "VLLM_USE_EXPERIMENTAL_PARSER_CONTEXT", False)
serving = _make_serving_instance_with_reasoning()