From 488b6da105222f4f8130b3aae4a0e67cfc61f522 Mon Sep 17 00:00:00 2001 From: Harry Mellor <19981378+hmellor@users.noreply.github.com> Date: Sun, 30 Aug 2026 06:21:22 -0700 Subject: [PATCH] [Doc] Fix griffe warnings in HYV4 tool parser (#54412) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Claude Opus 5 (1M context) --- vllm/tool_parsers/hy_v4_tool_parser.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/vllm/tool_parsers/hy_v4_tool_parser.py b/vllm/tool_parsers/hy_v4_tool_parser.py index c3d64a56f9..e89435dfa1 100644 --- a/vllm/tool_parsers/hy_v4_tool_parser.py +++ b/vllm/tool_parsers/hy_v4_tool_parser.py @@ -5,7 +5,8 @@ from __future__ import annotations import ast import json -from typing import Any, TypedDict +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any, TypedDict import regex as re @@ -26,6 +27,9 @@ from vllm.tokenizers import TokenizerLike from vllm.tool_parsers.abstract_tool_parser import ToolParser from vllm.tool_parsers.utils import partial_tag_overlap +if TYPE_CHECKING: + from xgrammar import StructuralTag + logger = init_logger(__name__) # ============================================================================= @@ -576,9 +580,9 @@ class HYV4ToolExtractor: previous_text: str, current_text: str, delta_text: str, - previous_token_ids, - current_token_ids, - delta_token_ids, + previous_token_ids: Sequence[int], + current_token_ids: Sequence[int], + delta_token_ids: Sequence[int], tools: list[ToolSchema] | None, *, guided: bool = False, @@ -989,7 +993,7 @@ class HYV4ToolParser(ToolParser): request: ChatCompletionRequest | ResponsesRequest, *, reasoning: bool = False, - ): + ) -> StructuralTag | None: """Build a structural tag matching HYV4's tool tokens. Overridden only to pass the per-checkpoint ``token_suffix`` through to @@ -1106,9 +1110,9 @@ class HYV4ToolParser(ToolParser): previous_text: str, current_text: str, delta_text: str, - previous_token_ids, - current_token_ids, - delta_token_ids, + previous_token_ids: Sequence[int], + current_token_ids: Sequence[int], + delta_token_ids: Sequence[int], request: ChatCompletionRequest, ) -> DeltaMessage | None: delta = self._extractor.extract_tool_calls_streaming(