The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
chore(typing): clear fresh tech debt from the Aug 25 window
Devin AId675b904e0e4
diff --git a/basedpyright-code-budget.json b/basedpyright-code-budget.jsonindex e3bac754074..6ce2f43e5ce 100644--- a/basedpyright-code-budget.json+++ b/basedpyright-code-budget.json@@ -1,6 +1,6 @@{"reportAny": {- "limit": 18505+ "limit": 18494},"reportArgumentType": {"limit": 2564@@ -24,7 +24,7 @@"limit": 19},"reportExplicitAny": {- "limit": 5976+ "limit": 5968},"reportFunctionMemberAccess": {"limit": 7@@ -57,7 +57,7 @@"limit": 5659},"reportMissingTypeArgument": {- "limit": 15504+ "limit": 15494},"reportMissingTypeStubs": {"limit": 40@@ -105,13 +105,13 @@"limit": 109},"reportUnknownMemberType": {- "limit": 38828+ "limit": 38818},"reportUnknownParameterType": {- "limit": 19847+ "limit": 19838},"reportUnknownVariableType": {- "limit": 30386+ "limit": 30371},"reportUnnecessaryCast": {"limit": 117diff --git a/litellm/integrations/custom_logger.py b/litellm/integrations/custom_logger.pyindex c957fd6e61e..41caf732db0 100644--- a/litellm/integrations/custom_logger.py+++ b/litellm/integrations/custom_logger.py@@ -295,7 +295,7 @@ class CustomLogger: # https://docs.litellm.ai/docs/observability/custom_callbacasync def async_post_call_failure_deployment_hook(self,- request_data: Mapping[str, Any],+ request_data: Mapping[str, object],exception: Exception,call_type: CallTypes | None,fallback_depth: int | None = None,diff --git a/litellm/integrations/prometheus.py b/litellm/integrations/prometheus.pyindex 8b23d1283f1..467ec72dc4a 100644--- a/litellm/integrations/prometheus.py+++ b/litellm/integrations/prometheus.py@@ -2495,12 +2495,12 @@ class PrometheusLogger(CustomLogger):return Nonedef _get_user_email() -> str | None:- val = _metadata.get("user_api_key_user_email")- if val is not None:- return val- val = _litellm_params_metadata.get("user_api_key_user_email")- if val is not None:- return val+ from_metadata: Final = _metadata.get("user_api_key_user_email")+ if from_metadata is not None:+ return from_metadata+ from_params: Final = _litellm_params_metadata.get("user_api_key_user_email")+ if from_params is not None:+ return from_paramsif user_api_key_auth is not None:return self._safe_get(user_api_key_auth, "user_email")return Nonediff --git a/litellm/litellm_core_utils/redact_messages.py b/litellm/litellm_core_utils/redact_messages.pyindex 064228bf8d7..9402d465712 100644--- a/litellm/litellm_core_utils/redact_messages.py+++ b/litellm/litellm_core_utils/redact_messages.py@@ -10,6 +10,7 @@import asyncioimport copyimport inspect+from collections.abc import Mappingfrom typing import TYPE_CHECKING, Any, Finalimport litellm@@ -191,7 +192,7 @@ def _redact_standard_logging_object(model_call_details: dict):standard_logging_object["response"] = {"text": redacted_str}-def _redact_tool_calls_dict(message: dict) -> None:+def _redact_tool_calls_dict(message: Mapping[str, object]) -> None:"""Redact tool call / function_call arguments in a dict-form message or delta."""tool_calls: Final = message.get("tool_calls")if isinstance(tool_calls, list):diff --git a/litellm/llms/bedrock_mantle/responses/transformation.py b/litellm/llms/bedrock_mantle/responses/transformation.pyindex 3e5dd4ff87d..2ea355fd369 100644--- a/litellm/llms/bedrock_mantle/responses/transformation.py+++ b/litellm/llms/bedrock_mantle/responses/transformation.py@@ -243,7 +243,7 @@ class BedrockMantleResponsesAPIConfig(BedrockMantleAuthMixin, OpenAIResponsesAPIreturn remaining_input, cls._filter_unsupported_tools(hoisted_tools)@staticmethod- def _agent_message_text(item: "Mapping[str, Any]") -> str:+ def _agent_message_text(item: "Mapping[str, object]") -> str:content: Final = item.get("content")if not isinstance(content, list):return ""@@ -254,7 +254,7 @@ class BedrockMantleResponsesAPIConfig(BedrockMantleAuthMixin, OpenAIResponsesAPI)@classmethod- def _normalize_agent_message_item(cls, item: "Mapping[str, Any]") -> "_RewrittenAssistantMessageItem | None":+ def _normalize_agent_message_item(cls, item: "Mapping[str, object]") -> "_RewrittenAssistantMessageItem | None":text: Final = cls._agent_message_text(item)if not text:return None@@ -266,7 +266,7 @@ class BedrockMantleResponsesAPIConfig(BedrockMantleAuthMixin, OpenAIResponsesAPIreturn rewritten@staticmethod- def _normalize_context_compaction_item(item: "Mapping[str, Any]") -> "_RewrittenCompactionItem | None":+ def _normalize_context_compaction_item(item: "Mapping[str, object]") -> "_RewrittenCompactionItem | None":encrypted_content: Final = item.get("encrypted_content")if not isinstance(encrypted_content, str) or not encrypted_content:return None@@ -274,7 +274,7 @@ class BedrockMantleResponsesAPIConfig(BedrockMantleAuthMixin, OpenAIResponsesAPIreturn rewritten@staticmethod- def _normalize_local_shell_call_item(item: "Mapping[str, Any]") -> "_RewrittenFunctionCallItem | None":+ def _normalize_local_shell_call_item(item: "Mapping[str, object]") -> "_RewrittenFunctionCallItem | None":call_id: Final = item.get("call_id")if not isinstance(call_id, str) or not call_id:return Nonediff --git a/litellm/types/integrations/prometheus.py b/litellm/types/integrations/prometheus.pyindex f6c8a011b86..b9dc6a1aad6 100644--- a/litellm/types/integrations/prometheus.py+++ b/litellm/types/integrations/prometheus.py@@ -3,7 +3,7 @@ from collections.abc import Mapping, Sequencefrom dataclasses import MISSING, dataclass, field, fieldsfrom enum import Enumfrom types import MappingProxyType-from typing import Any, ClassVar, Final, Literal+from typing import Any, ClassVar, Final, Literal, castimport litellm@@ -326,15 +326,16 @@ def validate_prometheus_deployment_and_latency_caller_identity() -> str:)-def validate_caller_identity_settings(litellm_settings: Mapping[str, Any]) -> None:+def validate_caller_identity_settings(litellm_settings: Mapping[str, object]) -> None:"""Store the caller-identity mode from litellm_settings and validate it togetherwith prometheus_metrics_config, raising on an invalid value or on include_labelsthat request a label the selected mode removes."""if "prometheus_deployment_and_latency_caller_identity" not in litellm_settings:return- litellm.prometheus_deployment_and_latency_caller_identity = litellm_settings[- "prometheus_deployment_and_latency_caller_identity"- ]+ litellm.prometheus_deployment_and_latency_caller_identity = cast(+ 'Literal["api_key_alias", "user_email", "both"]',+ litellm_settings["prometheus_deployment_and_latency_caller_identity"],+ ) # cast-ok: validated on the next line, which raises on an invalid valuecaller_identity_mode: Final = validate_prometheus_deployment_and_latency_caller_identity()if caller_identity_mode != "user_email":returndiff --git a/litellm/utils.py b/litellm/utils.pyindex 802dc151428..1b672018507 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -1292,7 +1292,7 @@ async def async_post_call_success_deployment_hook(async def async_post_call_failure_deployment_hook(- request_data: Mapping[str, Any], exception: Exception, call_type: str+ request_data: Mapping[str, object], exception: Exception, call_type: str) -> None:"""Notify CustomLogger callbacks that a deployment attempt failed.diff --git a/ruff-strict-budget.json b/ruff-strict-budget.jsonindex b6768c40988..a6aea082b37 100644--- a/ruff-strict-budget.json+++ b/ruff-strict-budget.json@@ -12,10 +12,10 @@"limit": 2012},"ANN202": {- "limit": 849+ "limit": 848},"ANN204": {- "limit": 708+ "limit": 707},"ANN205": {"limit": 112@@ -24,7 +24,7 @@"limit": 133},"ANN401": {- "limit": 1157+ "limit": 1155},"ASYNC230": {"limit": 11diff --git a/type-discipline-budget.json b/type-discipline-budget.jsonindex 31f3b29286a..2b8c36208f1 100644--- a/type-discipline-budget.json+++ b/type-discipline-budget.json@@ -1,9 +1,9 @@{"LIT001": {- "limit": 22749+ "limit": 22741},"LIT002": {- "limit": 26866+ "limit": 26865},"LIT003": {"limit": 269@@ -27,7 +27,7 @@"limit": 0},"LIT010": {- "limit": 16655+ "limit": 16638},"LIT011": {"limit": 5585