fix: fix linting errors

This commit is contained in:
Krrish Dholakia 2025-10-25 16:18:54 -07:00
parent 0f7e1acfc6
commit ef2c50c408
6 changed files with 15 additions and 14 deletions

View file

@ -13,7 +13,7 @@ Pattern Overview:
"""
import asyncio
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, cast
from typing import TYPE_CHECKING, Any, Coroutine, Dict, List, Optional, Tuple, cast
from litellm._logging import verbose_proxy_logger
from litellm.llms.base_llm.guardrail_translation.base_translation import BaseTranslation
@ -49,7 +49,7 @@ class AnthropicMessagesHandler(BaseTranslation):
if messages is None:
return data
tasks = []
tasks: List[Coroutine[Any, Any, str]] = []
task_mappings: List[Tuple[int, Optional[int]]] = []
# Track (message_index, content_index) for each task
# content_index is None for string content, int for list content
@ -166,7 +166,7 @@ class AnthropicMessagesHandler(BaseTranslation):
)
return response
tasks = []
tasks: List[Coroutine[Any, Any, str]] = []
task_mappings: List[Tuple[int, Optional[int]]] = []
# Track (choice_index, content_index) for each task

View file

@ -15,7 +15,7 @@ This pattern can be replicated for other message formats (e.g., Anthropic).
"""
import asyncio
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, cast
from typing import TYPE_CHECKING, Any, Coroutine, Dict, List, Optional, Tuple, cast
import litellm
from litellm._logging import verbose_proxy_logger
@ -50,7 +50,7 @@ class OpenAIChatCompletionsHandler(BaseTranslation):
if messages is None:
return data
tasks = []
tasks: List[Coroutine[Any, Any, str]] = []
task_mappings: List[Tuple[int, Optional[int]]] = []
# Track (message_index, content_index) for each task
# content_index is None for string content, int for list content
@ -168,7 +168,7 @@ class OpenAIChatCompletionsHandler(BaseTranslation):
)
return response
tasks = []
tasks: List[Coroutine[Any, Any, str]] = []
task_mappings: List[Tuple[int, Optional[int]]] = []
# Track (choice_index, content_index) for each task

View file

@ -29,7 +29,7 @@ Output: response.output is List[GenericResponseOutputItem] where each has:
"""
import asyncio
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union, cast
from typing import TYPE_CHECKING, Any, Coroutine, List, Optional, Tuple, Union, cast
from litellm._logging import verbose_proxy_logger
from litellm.llms.base_llm.guardrail_translation.base_translation import BaseTranslation
@ -79,7 +79,7 @@ class OpenAIResponsesHandler(BaseTranslation):
if not isinstance(input_data, list):
return data
tasks = []
tasks: List[Coroutine[Any, Any, str]] = []
task_mappings: List[Tuple[int, Optional[int]]] = []
# Track (message_index, content_index) for each task
# content_index is None for string content, int for list content
@ -113,9 +113,9 @@ class OpenAIResponsesHandler(BaseTranslation):
async def _extract_input_text_and_create_tasks(
self,
message: Dict[str, Any],
message: Any, # Can be Dict[str, Any] or ResponseInputParam
msg_idx: int,
tasks: List,
tasks: List[Coroutine[Any, Any, str]],
task_mappings: List[Tuple[int, Optional[int]]],
guardrail_to_apply: "CustomGuardrail",
) -> None:
@ -144,7 +144,7 @@ class OpenAIResponsesHandler(BaseTranslation):
async def _apply_guardrail_responses_to_input(
self,
messages: List[Dict[str, Any]],
messages: Any, # Can be List[Dict[str, Any]] or ResponseInputParam
responses: List[str],
task_mappings: List[Tuple[int, Optional[int]]],
) -> None:
@ -200,7 +200,7 @@ class OpenAIResponsesHandler(BaseTranslation):
)
return response
tasks = []
tasks: List[Coroutine[Any, Any, str]] = []
task_mappings: List[Tuple[int, int]] = []
# Track (output_item_index, content_index) for each task

View file

@ -216,7 +216,7 @@ class GraySwanGuardrail(CustomGuardrail):
verbose_proxy_logger.debug("GraySwan Guardrail: post-call hook triggered")
response_dict = response.model_dump() if hasattr(response, "model_dump") else {}
response_dict = response.model_dump() if hasattr(response, "model_dump") else {} # type: ignore[union-attr]
response_messages = [
msg if isinstance(msg, dict) else msg.model_dump()
for choice in response_dict.get("choices", [])

View file

@ -284,7 +284,7 @@ class PillarGuardrail(CustomGuardrail):
verbose_proxy_logger.debug("Pillar Guardrail: Post-call hook")
# Extract response messages in the format Pillar expects
response_dict = response.model_dump() if hasattr(response, "model_dump") else {}
response_dict = response.model_dump() if hasattr(response, "model_dump") else {} # type: ignore[union-attr]
response_messages = [
choice.get("message")
for choice in response_dict.get("choices", [])

View file

@ -926,6 +926,7 @@ async def test_model_connection(
"batch",
"rerank",
"realtime",
"responses",
"ocr",
]
] = fastapi.Body("chat", description="The mode to test the model with"),