[CI] Ignore ruff D209, rejoin the docstrings it split, and silence incompatible-rule warnings (#57212)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
1085b64425
commit
651a88c09a
@@ -341,8 +341,7 @@ class TestStreamingExtraction:
|
||||
|
||||
def test_mtp_streaming_massive_chunk(self, parser, mock_request):
|
||||
"""Simulates MTP predicting text, tool calls,
|
||||
and trailing text all in a single chunk.
|
||||
"""
|
||||
and trailing text all in a single chunk."""
|
||||
chunks = [
|
||||
"Sure! "
|
||||
'<|tools_prefix|>[{"get_weather": {"location": "London"}}]<|tools_suffix|>'
|
||||
@@ -375,8 +374,7 @@ class TestStreamingExtraction:
|
||||
|
||||
def test_mtp_streaming_skip_and_catch_up(self, parser, mock_request):
|
||||
"""Simulates MTP chunks that jump over entire tools
|
||||
(e.g., from middle of tool 1 to middle of tool 3).
|
||||
"""
|
||||
(e.g., from middle of tool 1 to middle of tool 3)."""
|
||||
chunks = [
|
||||
'<|tools_prefix|>[{"t1": {"a": 1}',
|
||||
'}, {"t2": {"b": 2}}, {"t3": {"c": 3',
|
||||
@@ -395,8 +393,7 @@ class TestStreamingExtraction:
|
||||
|
||||
def test_vllm_streaming_character_by_character(self, parser, mock_request):
|
||||
"""Simulates worst-case vLLM fragmentation where
|
||||
chunks arrive character-by-character.
|
||||
"""
|
||||
chunks arrive character-by-character."""
|
||||
text = (
|
||||
'Hi <|tools_prefix|>[{"get_weather": '
|
||||
'{"location": "London"}}]<|tools_suffix|> '
|
||||
@@ -414,8 +411,7 @@ class TestStreamingExtraction:
|
||||
|
||||
def test_vllm_streaming_empty_deltas(self, parser, mock_request):
|
||||
"""Simulates vLLM stream producing empty string chunks
|
||||
(e.g., hidden tokens or artifacts).
|
||||
"""
|
||||
(e.g., hidden tokens or artifacts)."""
|
||||
chunks = [
|
||||
"Wait",
|
||||
"",
|
||||
|
||||
@@ -173,8 +173,7 @@ class TestExtractToolCalls:
|
||||
|
||||
def test_string_attr_true_coerced_by_schema(self):
|
||||
"""string="true" delivers a string, but the engine's schema-aware
|
||||
type fixer coerces it to the schema type (integer).
|
||||
"""
|
||||
type fixer coerces it to the schema type (integer)."""
|
||||
tool = ChatCompletionToolsParam(
|
||||
function=FunctionDefinition(
|
||||
name="score",
|
||||
@@ -288,8 +287,7 @@ class TestExtractToolCalls:
|
||||
|
||||
def test_string_attr_true_coerced_by_composed_schema(self):
|
||||
"""string="true" delivers a JSON string, but the engine's schema-aware
|
||||
type fixer coerces it to the composed schema type (object).
|
||||
"""
|
||||
type fixer coerces it to the composed schema type (object)."""
|
||||
tool = ChatCompletionToolsParam(
|
||||
function=FunctionDefinition(
|
||||
name="set_timer",
|
||||
@@ -323,8 +321,7 @@ class TestExtractToolCalls:
|
||||
|
||||
def test_arguments_wrapper_repaired(self):
|
||||
"""A single 'arguments' wrapper parameter must be unwrapped when it
|
||||
is not part of the tool schema and the inner object matches schema fields.
|
||||
"""
|
||||
is not part of the tool schema and the inner object matches schema fields."""
|
||||
tool = ChatCompletionToolsParam(
|
||||
function=FunctionDefinition(
|
||||
name="get_weather",
|
||||
@@ -495,8 +492,7 @@ class TestExtractToolCalls:
|
||||
|
||||
def test_null_coerced_back_to_string_by_schema(self):
|
||||
"""string="false" with 'null' is json-parsed to None, but the
|
||||
engine's schema fixer coerces it back to "null" for string schemas.
|
||||
"""
|
||||
engine's schema fixer coerces it back to "null" for string schemas."""
|
||||
tool = ChatCompletionToolsParam(
|
||||
function=FunctionDefinition(
|
||||
name="echo",
|
||||
@@ -659,8 +655,7 @@ class TestExtractToolCallsStreaming:
|
||||
|
||||
def test_string_attr_true_coerced_by_schema_streaming(self):
|
||||
"""Streaming: string='true' delivers a string but the engine's
|
||||
schema fixer coerces it to the schema type (integer).
|
||||
"""
|
||||
schema fixer coerces it to the schema type (integer)."""
|
||||
tool = ChatCompletionToolsParam(
|
||||
function=FunctionDefinition(
|
||||
name="score",
|
||||
@@ -976,8 +971,7 @@ class TestExtractToolCallsStreaming:
|
||||
|
||||
def test_no_marker_leak_chunked(self, parser):
|
||||
"""Chunked streaming must NOT leak DSML start-marker fragments
|
||||
as content (GitHub #40801).
|
||||
"""
|
||||
as content (GitHub #40801)."""
|
||||
full_text = build_tool_call("fn", {"k": "v"})
|
||||
deltas = self._stream_chunked(parser, full_text, chunk_size=5)
|
||||
content = "".join(d.content for d in deltas if d.content is not None)
|
||||
@@ -987,8 +981,7 @@ class TestExtractToolCallsStreaming:
|
||||
|
||||
def test_no_marker_leak_with_prefix_chunked(self, parser):
|
||||
"""Content before a tool call must not include start-marker
|
||||
fragments when chunked (GitHub #40801).
|
||||
"""
|
||||
fragments when chunked (GitHub #40801)."""
|
||||
full_text = "Hello!" + build_tool_call("fn", {"a": "b"})
|
||||
deltas = self._stream_chunked(parser, full_text, chunk_size=5)
|
||||
content = "".join(d.content for d in deltas if d.content is not None)
|
||||
@@ -1000,8 +993,7 @@ class TestExtractToolCallsStreaming:
|
||||
|
||||
def test_no_marker_leak_char_by_char(self, parser):
|
||||
"""Character-by-character streaming must not leak marker
|
||||
fragments (GitHub #40801).
|
||||
"""
|
||||
fragments (GitHub #40801)."""
|
||||
full_text = build_tool_call("fn", {"k": "v"})
|
||||
deltas = self._stream_chunked(parser, full_text, chunk_size=1)
|
||||
content = "".join(d.content for d in deltas if d.content is not None)
|
||||
@@ -1011,8 +1003,7 @@ class TestExtractToolCallsStreaming:
|
||||
|
||||
def test_no_marker_leak_all_split_points(self, parser):
|
||||
"""Start token split at every possible boundary must not
|
||||
leak (GitHub #40801).
|
||||
"""
|
||||
leak (GitHub #40801)."""
|
||||
for chunk_size in range(1, len(FC_START) + 2):
|
||||
p = make_parser()
|
||||
full_text = build_tool_call("fn", {"k": "v"})
|
||||
@@ -1024,8 +1015,7 @@ class TestExtractToolCallsStreaming:
|
||||
|
||||
def test_false_partial_marker_emitted(self, parser):
|
||||
"""Text ending with a prefix of the start token that turns out
|
||||
NOT to be a marker must still be emitted as content.
|
||||
"""
|
||||
NOT to be a marker must still be emitted as content."""
|
||||
full_text = "<|DSM some regular text"
|
||||
deltas = self._stream_chunked(parser, full_text, chunk_size=3)
|
||||
content = "".join(d.content for d in deltas if d.content is not None)
|
||||
|
||||
@@ -124,8 +124,7 @@ def mock_request():
|
||||
|
||||
class TestParseGemma4Args:
|
||||
"""Values are returned as strings; type coercion to proper JSON types
|
||||
happens at the engine layer.
|
||||
"""
|
||||
happens at the engine layer."""
|
||||
|
||||
def test_empty_string(self):
|
||||
assert _parse_gemma4_args("") == {}
|
||||
|
||||
@@ -18,8 +18,7 @@ from vllm.tool_parsers import ToolParser, ToolParserManager
|
||||
@pytest.fixture(scope="function")
|
||||
def default_tokenizer() -> TokenizerLike:
|
||||
"""Override module-scoped default_tokenizer because gigachat tests
|
||||
mutate the tokenizer via ``add_tokens``.
|
||||
"""
|
||||
mutate the tokenizer via ``add_tokens``."""
|
||||
return AutoTokenizer.from_pretrained("openai-community/gpt2")
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
"""Named tool choice for Kimi K3: allowed when the XTML structural tag is
|
||||
attached (strict tool calling), rejected otherwise.
|
||||
"""
|
||||
attached (strict tool calling), rejected otherwise."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -416,8 +416,7 @@ def test_tool_call(
|
||||
def test_empty_tool_call_block(body: str, lfm2_tokenizer: TokenizerLike):
|
||||
"""An empty block ([] or [ ]) means the model called no tools; it must
|
||||
not report tools_called=True with zero tool calls (the invariant
|
||||
run_tool_extraction asserts).
|
||||
"""
|
||||
run_tool_extraction asserts)."""
|
||||
cls = ToolParserManager.get_tool_parser("lfm2")
|
||||
model_output = f"{TOOL_CALL_START}[{body}]{TOOL_CALL_END}"
|
||||
|
||||
@@ -437,8 +436,7 @@ def test_whitespace_after_start_token(lfm2_tokenizer: TokenizerLike):
|
||||
not break parsing. The streaming path used to feed the indented text to
|
||||
ast.parse verbatim, so every completion candidate raised
|
||||
IndentationError and the call was silently dropped (non-streaming
|
||||
stripped it and succeeded).
|
||||
"""
|
||||
stripped it and succeeded)."""
|
||||
cls = ToolParserManager.get_tool_parser("lfm2")
|
||||
model_output = f"{TOOL_CALL_START} [{SIMPLE_FUNCTION_OUTPUT}]{TOOL_CALL_END}"
|
||||
|
||||
@@ -478,8 +476,7 @@ def test_streaming_full_block_and_trailing_in_single_delta(
|
||||
):
|
||||
"""The entire <|tool_call_start|>[...]<|tool_call_end|> block plus
|
||||
trailing assistant text arrive in one delta. Trailing content must
|
||||
still be emitted — not silently dropped.
|
||||
"""
|
||||
still be emitted — not silently dropped."""
|
||||
tool_parser: ToolParser = ToolParserManager.get_tool_parser("lfm2")(lfm2_tokenizer)
|
||||
full_text = f"{TOOL_CALL_START}[{SIMPLE_FUNCTION_OUTPUT}]{TOOL_CALL_END}\nDone."
|
||||
|
||||
@@ -494,8 +491,7 @@ def test_streaming_leading_content_and_full_block_in_single_delta(
|
||||
lfm2_tokenizer: TokenizerLike,
|
||||
):
|
||||
"""Leading assistant text plus the entire tool block arrive in one
|
||||
delta. Leading content must be emitted — not silently dropped.
|
||||
"""
|
||||
delta. Leading content must be emitted — not silently dropped."""
|
||||
tool_parser: ToolParser = ToolParserManager.get_tool_parser("lfm2")(lfm2_tokenizer)
|
||||
full_text = (
|
||||
f"Let me check. {TOOL_CALL_START}[{SIMPLE_FUNCTION_OUTPUT}]{TOOL_CALL_END}"
|
||||
@@ -512,8 +508,7 @@ def test_streaming_leading_block_and_trailing_in_single_delta(
|
||||
lfm2_tokenizer: TokenizerLike,
|
||||
):
|
||||
"""Leading text + complete tool block + trailing text in one delta.
|
||||
Both leading and trailing content must be preserved.
|
||||
"""
|
||||
Both leading and trailing content must be preserved."""
|
||||
tool_parser: ToolParser = ToolParserManager.get_tool_parser("lfm2")(lfm2_tokenizer)
|
||||
full_text = (
|
||||
"Let me check. "
|
||||
@@ -534,8 +529,7 @@ def test_echoed_tool_call_body_not_leaked_to_content(
|
||||
"""LFM2 sometimes emits the tool call body again after the first
|
||||
<|tool_call_end|>, capped with a second <|tool_call_end|>. The
|
||||
echoed body must not surface as assistant content — neither in
|
||||
streaming nor non-streaming paths.
|
||||
"""
|
||||
streaming nor non-streaming paths."""
|
||||
tool_parser: ToolParser = ToolParserManager.get_tool_parser("lfm2")(lfm2_tokenizer)
|
||||
body = (
|
||||
"[grocery.orderIngredients("
|
||||
@@ -570,8 +564,7 @@ def test_streaming_char_by_char_multi_dict_list(lfm2_tokenizer: TokenizerLike):
|
||||
character at a time. Every prefix lands in some partial-parse state
|
||||
(mid-key, mid-value, open quote inside dict, empty dict, etc.). The
|
||||
parser must not raise — incomplete prefixes should silently wait for
|
||||
more text instead of logging exceptions.
|
||||
"""
|
||||
more text instead of logging exceptions."""
|
||||
tool_parser: ToolParser = ToolParserManager.get_tool_parser("lfm2")(lfm2_tokenizer)
|
||||
full_text = (
|
||||
f"{TOOL_CALL_START}[grocery.orderIngredients("
|
||||
@@ -602,8 +595,7 @@ def test_streaming_char_by_char_multi_dict_list(lfm2_tokenizer: TokenizerLike):
|
||||
def test_streaming_dotted_name_in_single_delta(lfm2_tokenizer: TokenizerLike):
|
||||
"""A pythonic call with a dotted/attribute function name (e.g.
|
||||
``domain.method(arg=...)``) must be parsed correctly in streaming mode
|
||||
just as in non-streaming mode.
|
||||
"""
|
||||
just as in non-streaming mode."""
|
||||
tool_parser: ToolParser = ToolParserManager.get_tool_parser("lfm2")(lfm2_tokenizer)
|
||||
full_text = f"{TOOL_CALL_START}[{DOTTED_NAME_FUNCTION_OUTPUT}]{TOOL_CALL_END}"
|
||||
|
||||
@@ -619,8 +611,7 @@ def test_adjust_request_disables_skip_special_tokens(
|
||||
"""When tools are present, the parser must force
|
||||
``skip_special_tokens=False`` so the engine does not strip the
|
||||
<|tool_call_start|>/<|tool_call_end|> sentinels before they reach the
|
||||
parser.
|
||||
"""
|
||||
parser."""
|
||||
from vllm.entrypoints.openai.chat_completion.protocol import (
|
||||
ChatCompletionRequest,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user