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:
@@ -6,8 +6,6 @@ Run `pytest tests/samplers/test_no_bad_words.py`.
|
||||
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from transformers import AutoTokenizer
|
||||
|
||||
from vllm import LLM, SamplingParams
|
||||
@@ -18,7 +16,7 @@ def _generate(
|
||||
prompt: str,
|
||||
num_prompt_tokens: int,
|
||||
temperature: float = 0,
|
||||
bad_words: Optional[list[str]] = None,
|
||||
bad_words: list[str] | None = None,
|
||||
) -> list[int]:
|
||||
sampling_params = SamplingParams(
|
||||
temperature=temperature,
|
||||
@@ -60,7 +58,7 @@ class TestOneTokenBadWord:
|
||||
output_token_ids = self._generate(llm, bad_words=[self.TARGET_TOKEN])
|
||||
assert self.target_token_id not in output_token_ids
|
||||
|
||||
def _generate(self, llm: LLM, bad_words: Optional[list[str]] = None) -> list[int]:
|
||||
def _generate(self, llm: LLM, bad_words: list[str] | None = None) -> list[int]:
|
||||
return _generate(
|
||||
llm=llm,
|
||||
prompt=self.PROMPT,
|
||||
@@ -155,7 +153,7 @@ class TestTwoTokenBadWord:
|
||||
self.neighbour_token_id2 in output_token_ids
|
||||
)
|
||||
|
||||
def _generate(self, llm: LLM, bad_words: Optional[list[str]] = None) -> list[int]:
|
||||
def _generate(self, llm: LLM, bad_words: list[str] | None = None) -> list[int]:
|
||||
return _generate(
|
||||
llm=llm,
|
||||
prompt=self.PROMPT,
|
||||
|
||||
Reference in New Issue
Block a user