[CI] Fix mypy for vllm/reasoning (#35742)

Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Martin Hickey
2026-03-12 12:21:33 +00:00
committed by GitHub
co-authored by Harry Mellor
parent 5282c7d4d0
commit 7f1f36bf91
21 changed files with 143 additions and 158 deletions
+5 -3
View File
@@ -4,7 +4,7 @@
import functools
import json
from collections.abc import Collection, Set
from collections.abc import Collection, Sequence, Set
from pathlib import Path
from typing import Any, Literal, overload
@@ -348,7 +348,9 @@ class Grok2Tokenizer(TokenizerLike):
tokens = self._maybe_truncate(tokens, max_length)
return tokens
def decode(self, ids: list[int] | int, skip_special_tokens: bool = False) -> str:
def decode(
self, ids: Sequence[int] | int, skip_special_tokens: bool = False
) -> str:
if isinstance(ids, int):
ids = [ids]
if skip_special_tokens:
@@ -371,7 +373,7 @@ class Grok2Tokenizer(TokenizerLike):
return [self._token_to_id.get(token, self._unk_token_id) for token in tokens]
def convert_ids_to_tokens(
self, ids: list[int], skip_special_tokens: bool = False
self, ids: Sequence[int], skip_special_tokens: bool = False
) -> list[str]:
tokens = []
for token_id in ids:
+5 -2
View File
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from collections.abc import Sequence
from pathlib import Path
from typing import TYPE_CHECKING, Any, cast, overload
@@ -434,7 +435,9 @@ class MistralTokenizer(TokenizerLike):
return_dict=False,
)
def decode(self, ids: list[int] | int, skip_special_tokens: bool = False) -> str:
def decode(
self, ids: Sequence[int] | int, skip_special_tokens: bool = False
) -> str:
# TODO(juliendenize): once https://github.com/huggingface/transformers/pull/41962
# is in, directly call self.transformers_tokenizer.decode(...).
if isinstance(ids, int):
@@ -512,7 +515,7 @@ class MistralTokenizer(TokenizerLike):
def convert_ids_to_tokens(
self,
ids: list[int],
ids: Sequence[int],
skip_special_tokens: bool = False,
) -> list[str]:
if not skip_special_tokens:
+5 -2
View File
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from collections.abc import Sequence
from pathlib import Path
from typing import TYPE_CHECKING, Any, Protocol, overload
@@ -116,12 +117,14 @@ class TokenizerLike(Protocol):
def convert_tokens_to_string(self, tokens: list[str]) -> str:
raise NotImplementedError
def decode(self, ids: list[int] | int, skip_special_tokens: bool = False) -> str:
def decode(
self, ids: Sequence[int] | int, skip_special_tokens: bool = False
) -> str:
raise NotImplementedError
def convert_ids_to_tokens(
self,
ids: list[int],
ids: Sequence[int],
skip_special_tokens: bool = False,
) -> list[str]:
raise NotImplementedError