fix(mypy): resolve missing return statements and type casting issues

This commit is contained in:
Shin 2026-02-07 01:14:02 +00:00
parent 0a55571f75
commit 0337fa79ea
3 changed files with 6 additions and 4 deletions

View file

@ -706,7 +706,7 @@ def _count_content_list(
if isinstance(c, str):
num_tokens += count_function(c)
elif c["type"] == "text":
num_tokens += count_function(c.get("text", ""))
num_tokens += count_function(str(c.get("text", "")))
elif c["type"] == "image_url":
image_url = c.get("image_url")
num_tokens += _count_image_tokens(
@ -722,7 +722,7 @@ def _count_content_list(
elif c["type"] == "thinking":
# Claude extended thinking content block
# Count the thinking text and skip signature (opaque signature blob)
thinking_text = c.get("thinking", "")
thinking_text = str(c.get("thinking", ""))
if thinking_text:
num_tokens += count_function(thinking_text)
else:

View file

@ -1,6 +1,6 @@
# litellm/proxy/guardrails/guardrail_hooks/pangea.py
import os
from typing import TYPE_CHECKING, Any, Optional, Type
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Type, cast
from fastapi import HTTPException
@ -253,7 +253,7 @@ class PangeaHandler(CustomGuardrail):
if not isinstance(response, ModelResponse):
return
else:
input_messages = data.get("messages")
input_messages = cast(List[Dict[Any, Any]], data.get("messages"))
if choices := response.get("choices"):
if isinstance(choices, list):

View file

@ -90,6 +90,7 @@ class LiteLLMCompletionTransformationHandler:
custom_llm_provider=custom_llm_provider,
litellm_metadata=kwargs.get("litellm_metadata", {}),
)
raise ValueError(f"Unexpected response type: {type(litellm_completion_response)}")
async def async_response_api_handler(
self,
@ -140,3 +141,4 @@ class LiteLLMCompletionTransformationHandler:
),
litellm_metadata=kwargs.get("litellm_metadata", {}),
)
raise ValueError(f"Unexpected response type: {type(litellm_completion_response)}")