mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
Fix 13 mypy type errors across 6 files
- in_flight_requests_middleware.py: Fix type: ignore error codes from [union-attr] to [attr-defined], add [arg-type] for Gauge **kwargs - transformation.py: Add [assignment] ignore for output_format reassignment, add fallback empty string for tool use id to fix arg-type - responses/main.py: Remove redundant type annotation on second secret_fields assignment to fix no-redef - streaming_iterator.py: Add [assignment] ignores for intermediate cache token assignments - handler.py: Add [typeddict-item] ignore for AnthropicMessagesRequest construction from dict - public_endpoints.py: Add [arg-type] ignore for _load_endpoints() return type mismatch with SupportedEndpoint model Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
This commit is contained in:
parent
467d93e433
commit
ba738a0596
6 changed files with 10 additions and 10 deletions
|
|
@ -65,7 +65,7 @@ def _build_responses_kwargs(
|
|||
if output_format:
|
||||
request_data["output_format"] = output_format
|
||||
|
||||
anthropic_request = AnthropicMessagesRequest(**request_data)
|
||||
anthropic_request = AnthropicMessagesRequest(**request_data) # type: ignore[typeddict-item]
|
||||
responses_kwargs = _ADAPTER.translate_request(anthropic_request)
|
||||
|
||||
if stream:
|
||||
|
|
|
|||
|
|
@ -188,8 +188,8 @@ class AnthropicResponsesStreamWrapper:
|
|||
if usage is not None:
|
||||
input_tokens = getattr(usage, "input_tokens", 0) or 0
|
||||
output_tokens = getattr(usage, "output_tokens", 0) or 0
|
||||
cache_creation_tokens = getattr(usage, "input_tokens_details", None)
|
||||
cache_read_tokens = getattr(usage, "output_tokens_details", None)
|
||||
cache_creation_tokens = getattr(usage, "input_tokens_details", None) # type: ignore[assignment]
|
||||
cache_read_tokens = getattr(usage, "output_tokens_details", None) # type: ignore[assignment]
|
||||
# Prefer direct cache fields if present
|
||||
cache_creation_tokens = getattr(usage, "cache_creation_input_tokens", 0) or 0
|
||||
cache_read_tokens = getattr(usage, "cache_read_input_tokens", 0) or 0
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ class LiteLLMAnthropicToResponsesAPIAdapter:
|
|||
output_format = anthropic_request.get("output_format")
|
||||
output_config = anthropic_request.get("output_config")
|
||||
if not isinstance(output_format, dict) and isinstance(output_config, dict):
|
||||
output_format = output_config.get("format")
|
||||
output_format = output_config.get("format") # type: ignore[assignment]
|
||||
if isinstance(output_format, dict) and output_format.get("type") == "json_schema":
|
||||
schema = output_format.get("schema")
|
||||
if schema:
|
||||
|
|
@ -392,7 +392,7 @@ class LiteLLMAnthropicToResponsesAPIAdapter:
|
|||
content.append(
|
||||
AnthropicResponseContentBlockToolUse(
|
||||
type="tool_use",
|
||||
id=item.call_id or item.id,
|
||||
id=item.call_id or item.id or "",
|
||||
name=item.name,
|
||||
input=input_data,
|
||||
).model_dump()
|
||||
|
|
|
|||
|
|
@ -41,13 +41,13 @@ class InFlightRequestsMiddleware:
|
|||
InFlightRequestsMiddleware._in_flight += 1
|
||||
gauge = InFlightRequestsMiddleware._get_gauge()
|
||||
if gauge is not None:
|
||||
gauge.inc() # type: ignore[union-attr]
|
||||
gauge.inc() # type: ignore[attr-defined]
|
||||
try:
|
||||
await self.app(scope, receive, send)
|
||||
finally:
|
||||
InFlightRequestsMiddleware._in_flight -= 1
|
||||
if gauge is not None:
|
||||
gauge.dec() # type: ignore[union-attr]
|
||||
gauge.dec() # type: ignore[attr-defined]
|
||||
|
||||
@staticmethod
|
||||
def get_count() -> int:
|
||||
|
|
@ -69,7 +69,7 @@ class InFlightRequestsMiddleware:
|
|||
InFlightRequestsMiddleware._gauge = Gauge(
|
||||
"litellm_in_flight_requests",
|
||||
"Number of HTTP requests currently in-flight on this uvicorn worker",
|
||||
**kwargs,
|
||||
**kwargs, # type: ignore[arg-type]
|
||||
)
|
||||
except Exception:
|
||||
InFlightRequestsMiddleware._gauge = None
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ async def get_supported_endpoints() -> SupportedEndpointsResponse:
|
|||
"""
|
||||
global _cached_endpoints
|
||||
if _cached_endpoints is None:
|
||||
_cached_endpoints = SupportedEndpointsResponse(endpoints=_load_endpoints())
|
||||
_cached_endpoints = SupportedEndpointsResponse(endpoints=_load_endpoints()) # type: ignore[arg-type]
|
||||
return _cached_endpoints
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ async def aresponses_api_with_mcp(
|
|||
)
|
||||
|
||||
# Extract MCP auth headers from the request to pass to MCP server
|
||||
secret_fields: Optional[Dict[str, Any]] = kwargs.get("secret_fields")
|
||||
secret_fields = kwargs.get("secret_fields")
|
||||
(
|
||||
mcp_auth_header,
|
||||
mcp_server_auth_headers,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue