Skip to content

Commit 5b65715

Browse files
committed
fix mypy
Signed-off-by: wwl2755 <wangwenlong2755@gmail.com>
1 parent 6e783bc commit 5b65715

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

tools/pre_commit/mypy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
FILES = [
2828
"vllm/*.py",
2929
"vllm/assets",
30+
"vllm/engine",
3031
"vllm/entrypoints",
3132
"vllm/inputs",
3233
"vllm/logging_utils",

vllm/engine/arg_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ def create_engine_config(
12431243
(self.model, self.tokenizer, self.speculative_config) = (
12441244
maybe_override_with_speculators(
12451245
model=self.model,
1246-
tokenizer=self.tokenizer,
1246+
tokenizer=self.tokenizer if self.tokenizer is not None else self.model,
12471247
revision=self.revision,
12481248
trust_remote_code=self.trust_remote_code,
12491249
vllm_speculative_config=self.speculative_config,
@@ -1685,7 +1685,7 @@ def _is_v1_supported_oracle(self, model_config: ModelConfig) -> bool:
16851685
return True
16861686

16871687
def _set_default_args(
1688-
self, usage_context: UsageContext, model_config: ModelConfig
1688+
self, usage_context: Optional[UsageContext], model_config: ModelConfig
16891689
) -> None:
16901690
"""Set Default Arguments for V1 Engine."""
16911691

vllm/multimodal/parse.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
Optional,
1414
TypeVar,
1515
Union,
16+
cast,
1617
)
1718

1819
import numpy as np
@@ -366,7 +367,8 @@ def _is_embeddings(
366367
if isinstance(data, torch.Tensor):
367368
return data.ndim == 3
368369
if is_list_of(data, torch.Tensor):
369-
return data[0].ndim == 2
370+
tensors = cast(list[torch.Tensor], data)
371+
return tensors[0].ndim == 2
370372

371373
return False
372374

@@ -434,7 +436,7 @@ def _parse_audio_data(
434436
elif isinstance(data, (np.ndarray, torch.Tensor)):
435437
data_items = [elem for elem in data]
436438
else:
437-
data_items = data
439+
data_items = data # type: ignore[assignment]
438440

439441
new_audios = list[np.ndarray]()
440442
for data_item in data_items:
@@ -498,7 +500,7 @@ def _parse_video_data(
498500
elif isinstance(data, tuple) and len(data) == 2:
499501
data_items = [data]
500502
else:
501-
data_items = data
503+
data_items = data # type: ignore[assignment]
502504

503505
new_videos = list[tuple[np.ndarray, Optional[dict[str, Any]]]]()
504506
metadata_lst: list[Optional[dict[str, Any]]] = []

vllm/transformers_utils/tokenizers/mistral.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,16 +350,17 @@ def __call__(
350350
# For list[str], original prompt text
351351
if is_list_of(text, str):
352352
input_ids_: list[list[int]] = []
353-
for p in text:
353+
text_strs = cast(list[str], text)
354+
for p in text_strs:
354355
each_input_ids = self.encode_one(p, truncation, max_length)
355356
input_ids_.append(each_input_ids)
356357
input_ids = input_ids_
357358
# For list[int], apply chat template output, already tokens.
358359
elif is_list_of(text, int):
359-
input_ids = text
360+
input_ids = cast(list[int], text)
360361
# For str, single prompt text
361362
else:
362-
input_ids = self.encode_one(text, truncation, max_length)
363+
input_ids = self.encode_one(cast(str, text), truncation, max_length)
363364
return BatchEncoding({"input_ids": input_ids})
364365

365366
def get_vocab(self) -> dict[str, int]:

0 commit comments

Comments
 (0)