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
+46 -23
View File
@@ -323,7 +323,8 @@ class TestEventsToDelta:
def test_multiple_arg_chunks_same_batch_coalesced(self):
"""Multiple events for the same tool in one batch must produce
at most one DeltaToolCall per index."""
at most one DeltaToolCall per index.
"""
engine = _make_engine()
events = [
SemanticEvent(EventType.TOOL_CALL_START, tool_index=0),
@@ -551,7 +552,8 @@ class TestPostToolContentDeferral:
"""Regression: content after TOOL_CALL_END in the same batch must not
produce a mixed DeltaMessage(content=..., tool_calls=...) — that causes
split_delta to reorder content before tool_calls, breaking the Responses
API state machine."""
API state machine.
"""
def test_text_after_tool_end_deferred(self):
engine = _make_engine()
@@ -605,7 +607,8 @@ class TestPostToolContentDeferral:
"""Deferred content from batch N must not mix with arg-continuation
tool events in batch N+1 — that creates a DeltaMessage with both
content and nameless tool_calls, which crashes the Responses API
state machine (name=None → Pydantic ValidationError)."""
state machine (name=None → Pydantic ValidationError).
"""
engine = _make_engine()
engine._content_has_nonws = True
@@ -834,7 +837,8 @@ class TestBuildExtractedResult:
class TestEngineBasedPath:
"""Tests for the _engine_based accumulation behavior in
DelegatingParser.parse_delta."""
DelegatingParser.parse_delta.
"""
def test_engine_based_true_when_both_parsers_engine(self):
r = SimpleNamespace(engine_based_streaming=True)
@@ -880,7 +884,8 @@ class TestEngineBasedPath:
class TestParseTokenIdPassthrough:
"""parse() must forward model_output_token_ids to _single_pass_parse
so that token-ID-based strict terminal matching is active."""
so that token-ID-based strict terminal matching is active.
"""
def test_literal_tool_tag_in_content_preserved_with_token_ids(self, mock_request):
engine = _make_engine(_hermes_config())
@@ -1104,7 +1109,8 @@ class TestAdapterFinishOnStreamEnd:
def test_lexer_buffer_flushed_on_finished(self):
"""Text buffered as a potential terminal prefix must be emitted
as content when the stream ends."""
as content when the stream ends.
"""
tokenizer = make_mock_tokenizer(_VOCAB)
parser = _CombinedDelegating(tokenizer)
request = _make_delegating_request()
@@ -1122,7 +1128,8 @@ class TestAdapterFinishOnStreamEnd:
def test_args_buffer_flushed_on_finished(self):
"""Pending arg buffer text must be emitted when stream ends
mid-tool-call (closing brace held back in buffer)."""
mid-tool-call (closing brace held back in buffer).
"""
tokenizer = make_mock_tokenizer(_VOCAB)
parser = _CombinedDelegating(tokenizer)
request = _make_delegating_request()
@@ -1358,7 +1365,8 @@ class TestSkipToolSpanForwarding:
class TestToolAdapterForwardsKwargs:
"""ParserEngineToolAdapter.__init__ must forward **kwargs to the
parser engine class so chat_template_kwargs reach model parsers."""
parser engine class so chat_template_kwargs reach model parsers.
"""
@pytest.mark.parametrize(
"enable_thinking,expected_state",
@@ -1388,7 +1396,8 @@ class TestToolAdapterForwardsKwargs:
class TestExtractContentIdsNoEmptyReturn:
"""extract_content_ids must return input_ids (not []) when there is
no THINK_END token ID and _reasoning_ended is True."""
no THINK_END token ID and _reasoning_ended is True.
"""
_NO_THINK_CONFIG = ParserEngineConfig(name="no_think_end", token_id_terminals={})
@@ -1786,7 +1795,8 @@ class TestDropSpecialTokens:
def test_drops_special_token_by_id_from_content(self):
"""A special token (not a configured terminal) is dropped when
it arrives as its actual token ID."""
it arrives as its actual token ID.
"""
config = ParserEngineConfig(
name="drop_content_test",
terminals={},
@@ -1821,7 +1831,8 @@ class TestDropSpecialTokens:
def test_drops_via_text_fallback_when_no_token_ids(self):
"""When no token IDs are provided, text-based lexer catches
drop tokens as a fallback."""
drop tokens as a fallback.
"""
engine = _make_engine(
vocab=_DROP_VOCAB,
special_tokens=list(_DROP_VOCAB.keys()),
@@ -1834,7 +1845,8 @@ class TestDropSpecialTokens:
def test_regular_tokens_spelling_special_survive(self):
"""Regular tokens that spell out a drop-token string survive
when token IDs prove they are not the special token."""
when token IDs prove they are not the special token.
"""
vocab = {**_DROP_VOCAB, "h": 72, "<": 73, "bos": 74, ">": 75, "w": 76}
engine = _make_engine(
vocab=vocab,
@@ -1850,7 +1862,8 @@ class TestDropSpecialTokens:
def test_configured_terminal_not_treated_as_drop(self):
"""Tokens already in config.terminals (like <think>) are handled
by the state machine, not the drop mechanism."""
by the state machine, not the drop mechanism.
"""
engine = _make_engine(
vocab=_DROP_VOCAB,
special_tokens=list(_DROP_VOCAB.keys()),
@@ -1905,7 +1918,8 @@ class TestDropSpecialTokens:
def test_drops_applied_with_skip_tool_parsing(self):
"""Drop tokens are always dropped, even with skip_tool_parsing.
DROP_TERMINALs have no transitions by construction, so no parser
pass can use them."""
pass can use them.
"""
for initial_state in (ParserState.REASONING, ParserState.CONTENT):
engine = _make_engine(
vocab=_DROP_VOCAB,
@@ -1921,7 +1935,8 @@ class TestDropSpecialTokens:
def test_transitions_unaffected_by_drop_in_reasoning_with_skip_tool_parsing(self):
"""With skip_tool_parsing in REASONING state, drop tokens are
removed but configured terminals still fire their transitions."""
removed but configured terminals still fire their transitions.
"""
engine = _make_engine(
vocab=_DROP_VOCAB,
special_tokens=list(_DROP_VOCAB.keys()),
@@ -1957,7 +1972,8 @@ class TestDropSpecialTokens:
def test_mixed_configured_and_drop_terminals(self):
"""Configured terminals trigger transitions while drop terminals
are silently removed in the same stream."""
are silently removed in the same stream.
"""
engine = _make_engine(
vocab=_DROP_VOCAB,
special_tokens=list(_DROP_VOCAB.keys()),
@@ -1981,7 +1997,8 @@ class TestTruncatedToolOpenerStreamParity:
"""Regression tests for #47137: when generation terminates inside a
``<tool_call>`` opener that has not been promoted to a tool call
(via ``max_tokens`` or a ``stop`` string), the non-streaming path
must drop the incomplete markup, matching the streaming path."""
must drop the incomplete markup, matching the streaming path.
"""
_QWEN3_VOCAB = {
"<tool_call>": 100,
@@ -2027,7 +2044,8 @@ class TestTruncatedToolOpenerStreamParity:
)
def test_truncated_opener_dropped_in_both_paths(self, mock_request, chunks):
"""A cutoff inside the opener yields no content and no tool calls
in both the non-streaming and streaming paths."""
in both the non-streaming and streaming paths.
"""
text = "".join(chunks)
_, content, tool_calls = self._make_parser().parse(
@@ -2040,7 +2058,8 @@ class TestTruncatedToolOpenerStreamParity:
def test_content_before_truncated_opener_preserved(self, mock_request):
"""Only the incomplete markup is dropped; content generated before
the opener is returned identically by both paths."""
the opener is returned identically by both paths.
"""
chunks = ["Checking the weather. ", "<tool_call>", "\n", "<function"]
text = "".join(chunks)
@@ -2054,7 +2073,8 @@ class TestTruncatedToolOpenerStreamParity:
def test_content_around_unpromoted_tool_block_stays_ordered(self, mock_request):
"""Text surrounding a complete-but-unparsable tool block keeps its
original order in the non-streaming path, matching streaming."""
original order in the non-streaming path, matching streaming.
"""
chunks = ["A ", "<tool_call>", "garbage", "</tool_call>", " B"]
text = "".join(chunks)
@@ -2068,7 +2088,8 @@ class TestTruncatedToolOpenerStreamParity:
def test_complete_tool_call_still_promoted(self, mock_request):
"""Sanity check: a complete tool call still parses in the
non-streaming path after the truncation fix."""
non-streaming path after the truncation fix.
"""
text = (
"<tool_call>\n"
"<function=get_weather>\n"
@@ -2088,7 +2109,8 @@ class TestThinkMarkupWithoutReasoningParser:
"""With no reasoning parser configured, reasoning markup is plain
content: engine-backed tool parsers must return it verbatim in both
the non-streaming and streaming paths, not consume the markers or
reclassify the block as reasoning and drop it."""
reclassify the block as reasoning and drop it.
"""
_VOCAB = {
"<think>": 90,
@@ -2154,7 +2176,8 @@ class TestThinkMarkupWithoutReasoningParser:
def test_think_block_preserved_alongside_tool_call(self, mock_request):
"""The tools-called branch also returns the tool parser's content;
a think block preceding a promoted tool call must survive in it."""
a think block preceding a promoted tool call must survive in it.
"""
think = "<think>plan</think>"
text = think + (
"<tool_call>\n"