[MyPy][3/N] Fix MyPy errors in test groups (part 3) (#55939)

Signed-off-by: Taimys <ffy2281693949@gmail.com>
Signed-off-by: Luyi Xiao <81631911+luyixiao95@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Luyi Xiao <81631911+luyixiao95@users.noreply.github.com>
Co-authored-by: Taimys <ffy2281693949@gmail.com>
Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Taimys
2026-09-30 11:06:07 +00:00
committed by GitHub
co-authored by Codex Luyi Xiao Taimys Harry Mellor Claude Opus 5.5
parent c4fa6f36a7
commit 5225f1bacb
118 changed files with 948 additions and 605 deletions
@@ -3,6 +3,7 @@
import string
from collections.abc import Sequence
from typing import cast
import pytest
@@ -10,6 +11,7 @@ from vllm.entrypoints.openai.chat_completion.protocol import ChatCompletionReque
from vllm.parser.parser_manager import ParserManager
from vllm.reasoning import ReasoningParserManager
from vllm.reasoning.k2_horizon_reasoning_parser import K2HorizonReasoningParser
from vllm.tokenizers import TokenizerLike
pytestmark = pytest.mark.skip_global_cleanup
@@ -59,6 +61,10 @@ class K2Tokenizer:
return "".join(inverse_vocab[token_id] for token_id in ids)
def _k2_tokenizer() -> TokenizerLike:
return cast(TokenizerLike, K2Tokenizer())
def _request(**kwargs) -> ChatCompletionRequest:
return ChatCompletionRequest(
model="k2-horizon",
@@ -70,7 +76,7 @@ def _request(**kwargs) -> ChatCompletionRequest:
@pytest.mark.parametrize("effort", ["high", "medium", "low"])
def test_reasoning_effort_selects_tokens(effort: str):
parser = K2HorizonReasoningParser(
K2Tokenizer(),
_k2_tokenizer(),
chat_template_kwargs={"reasoning_effort": effort},
)
@@ -78,7 +84,7 @@ def test_reasoning_effort_selects_tokens(effort: str):
def test_reasoning_effort_precedence_and_default():
tokenizer = K2Tokenizer()
tokenizer = _k2_tokenizer()
request = _request(
reasoning_effort="medium",
chat_template_kwargs={"reasoning_effort": "low"},
@@ -103,13 +109,13 @@ def test_reasoning_effort_precedence_and_default():
def test_invalid_reasoning_effort_raises(effort: str | None):
with pytest.raises(ValueError, match="Unsupported reasoning_effort"):
K2HorizonReasoningParser(
K2Tokenizer(),
_k2_tokenizer(),
chat_template_kwargs={"reasoning_effort": effort},
)
def test_non_streaming_explicit_and_implicit_boundaries():
parser = K2HorizonReasoningParser(K2Tokenizer())
parser = K2HorizonReasoningParser(_k2_tokenizer())
request = _request()
assert parser.extract_reasoning("<ifm|think>plan</ifm|think>answer", request) == (
@@ -126,7 +132,7 @@ def test_non_streaming_explicit_and_implicit_boundaries():
@pytest.mark.parametrize("reasoning", ["plan", " ", "\n", " \n"])
def test_character_split_reasoning_stream(reasoning: str):
parser = K2HorizonReasoningParser(K2Tokenizer())
parser = K2HorizonReasoningParser(_k2_tokenizer())
reasoning_parts: list[str] = []
content_parts: list[str] = []
@@ -150,7 +156,7 @@ def test_character_split_reasoning_stream(reasoning: str):
def test_latest_boundary_controls_reasoning_state():
tokenizer = K2Tokenizer()
tokenizer = _k2_tokenizer()
parser = K2HorizonReasoningParser(tokenizer)
vocab = tokenizer.get_vocab()
@@ -159,7 +165,7 @@ def test_latest_boundary_controls_reasoning_state():
def test_composed_streaming_reasoning_to_tool_handoff():
tokenizer = K2Tokenizer()
tokenizer = _k2_tokenizer()
tools = [
{
"type": "function",