Update Optional[x] -> x | None and Union[x, y] to x | y (#26633)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Harry Mellor
2025-10-12 17:51:31 +01:00
committed by GitHub
parent 9bb38130cb
commit 8fcaaf6a16
944 changed files with 9490 additions and 10121 deletions

View File

@@ -1,7 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from typing import TYPE_CHECKING, Any, Optional, Union
from typing import TYPE_CHECKING, Any
from vllm.transformers_utils.tokenizer import get_tokenizer
from vllm.transformers_utils.tokenizer_base import TokenizerBase, TokenizerRegistry
@@ -61,11 +61,11 @@ class TestTokenizer(TokenizerBase):
def __call__(
self,
text: Union[str, list[str], list[int]],
text_pair: Optional[str] = None,
text: str | list[str] | list[int],
text_pair: str | None = None,
add_special_tokens: bool = False,
truncation: bool = False,
max_length: Optional[int] = None,
max_length: int | None = None,
):
raise NotImplementedError()
@@ -79,17 +79,17 @@ class TestTokenizer(TokenizerBase):
self,
text: str,
truncation: bool = False,
max_length: Optional[int] = None,
max_length: int | None = None,
) -> list[int]:
raise NotImplementedError()
def encode(self, text: str, add_special_tokens: Optional[bool] = None) -> list[int]:
def encode(self, text: str, add_special_tokens: bool | None = None) -> list[int]:
raise NotImplementedError()
def apply_chat_template(
self,
messages: list["ChatCompletionMessageParam"],
tools: Optional[list[dict[str, Any]]] = None,
tools: list[dict[str, Any]] | None = None,
**kwargs,
) -> list[int]:
raise NotImplementedError()
@@ -97,9 +97,7 @@ class TestTokenizer(TokenizerBase):
def convert_tokens_to_string(self, tokens: list[str]) -> str:
raise NotImplementedError()
def decode(
self, ids: Union[list[int], int], skip_special_tokens: bool = True
) -> str:
def decode(self, ids: list[int] | int, skip_special_tokens: bool = True) -> str:
raise NotImplementedError()
def convert_ids_to_tokens(