Skip to content

Commit c9f09a4

Browse files
authored
[mypy] Fix mypy warnings in api_server.py (#11941)
Signed-off-by: Fred Reiss <frreiss@us.ibm.com>
1 parent d45cbe7 commit c9f09a4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

vllm/entrypoints/openai/api_server.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from contextlib import asynccontextmanager
1515
from functools import partial
1616
from http import HTTPStatus
17-
from typing import AsyncIterator, Optional, Set, Tuple
17+
from typing import AsyncIterator, Dict, Optional, Set, Tuple, Union
1818

1919
import uvloop
2020
from fastapi import APIRouter, FastAPI, HTTPException, Request
@@ -420,6 +420,8 @@ async def create_embedding(request: EmbeddingRequest, raw_request: Request):
420420
"use the Pooling API (`/pooling`) instead.")
421421

422422
res = await fallback_handler.create_pooling(request, raw_request)
423+
424+
generator: Union[ErrorResponse, EmbeddingResponse]
423425
if isinstance(res, PoolingResponse):
424426
generator = EmbeddingResponse(
425427
id=res.id,
@@ -494,7 +496,7 @@ async def create_score_v1(request: ScoreRequest, raw_request: Request):
494496
return await create_score(request, raw_request)
495497

496498

497-
TASK_HANDLERS = {
499+
TASK_HANDLERS: Dict[str, Dict[str, tuple]] = {
498500
"generate": {
499501
"messages": (ChatCompletionRequest, create_chat_completion),
500502
"default": (CompletionRequest, create_completion),
@@ -652,7 +654,7 @@ async def add_request_id(request: Request, call_next):
652654
module_path, object_name = middleware.rsplit(".", 1)
653655
imported = getattr(importlib.import_module(module_path), object_name)
654656
if inspect.isclass(imported):
655-
app.add_middleware(imported)
657+
app.add_middleware(imported) # type: ignore[arg-type]
656658
elif inspect.iscoroutinefunction(imported):
657659
app.middleware("http")(imported)
658660
else:

0 commit comments

Comments
 (0)