Skip to content

Commit

Permalink
[CI/Build] mypy: check vllm/inputs
Browse files Browse the repository at this point in the history
Enable `mypy` checks on `vllm/inputs` and add some casts to fix the
warnings present for this directory.

Part of issue vllm-project#3680

Signed-off-by: Russell Bryant <rbryant@redhat.com>
  • Loading branch information
russellb committed Oct 9, 2024
1 parent cdca899 commit 70e475f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tools/mypy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ run_mypy vllm/distributed
run_mypy vllm/engine
run_mypy vllm/entrypoints
run_mypy vllm/executor
#run_mypy vllm/inputs
run_mypy vllm/inputs
run_mypy vllm/logging
run_mypy vllm/lora
run_mypy vllm/model_executor
Expand Down
5 changes: 4 additions & 1 deletion vllm/inputs/parse.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Literal, Sequence, TypedDict, Union, overload
from typing import List, Literal, Sequence, TypedDict, Union, cast, overload

from typing_extensions import TypeIs

Expand Down Expand Up @@ -44,13 +44,16 @@ def parse_and_batch_prompt(

if is_list_of(prompt, str):
# case 2: array of strings
prompt = cast(List[str], prompt)
return [
ParsedText(content=elem, is_tokens=False) for elem in prompt
]
if is_list_of(prompt, int):
# case 3: array of tokens
prompt = cast(List[int], prompt)
return [ParsedTokens(content=prompt, is_tokens=True)]
if is_list_of(prompt, list):
prompt = cast(List[List[int]], prompt)
if len(prompt[0]) == 0:
raise ValueError("please provide at least one prompt")

Expand Down

0 comments on commit 70e475f

Please sign in to comment.