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
fix(mypy): fix type errors in files, opentelemetry, gemini transformation, and key management (#20161)
shin-bot-litellm6c497d29905f
diff --git a/litellm/files/main.py b/litellm/files/main.pyindex 93a10dac7a3..78e41bb5a68 100644--- a/litellm/files/main.py+++ b/litellm/files/main.py@@ -9,7 +9,7 @@ import asyncioimport contextvarsimport osimport time-import uuid+import uuid as uuid_modulefrom functools import partialfrom typing import Any, Coroutine, Dict, Literal, Optional, Union, cast@@ -451,7 +451,7 @@ def file_retrieve(stream=False,call_type="afile_retrieve" if _is_async else "file_retrieve",start_time=time.time(),- litellm_call_id=kwargs.get("litellm_call_id", str(uuid.uuid4())),+ litellm_call_id=kwargs.get("litellm_call_id", str(uuid_module.uuid4())),function_id=str(kwargs.get("id") or ""),)@@ -660,7 +660,7 @@ def file_delete(stream=False,call_type="afile_delete" if _is_async else "file_delete",start_time=time.time(),- litellm_call_id=kwargs.get("litellm_call_id", str(uuid.uuid4())),+ litellm_call_id=kwargs.get("litellm_call_id", str(uuid_module.uuid4())),function_id=str(kwargs.get("id") or ""),)@@ -793,7 +793,7 @@ def file_list(stream=False,call_type="afile_list" if _is_async else "file_list",start_time=time.time(),- litellm_call_id=kwargs.get("litellm_call_id", str(uuid.uuid4())),+ litellm_call_id=kwargs.get("litellm_call_id", str(uuid_module.uuid4())),function_id=str(kwargs.get("id", "")),)diff --git a/litellm/integrations/opentelemetry.py b/litellm/integrations/opentelemetry.pyindex 997dd044a65..18898be7dce 100644--- a/litellm/integrations/opentelemetry.py+++ b/litellm/integrations/opentelemetry.py@@ -1631,7 +1631,7 @@ class OpenTelemetry(CustomLogger):)except Exception as e:- self.handle_callback_failure(callback_name= self.callback_name)+ self.handle_callback_failure(callback_name=self.callback_name or "opentelemetry")verbose_logger.exception("OpenTelemetry logging error in set_attributes %s", str(e))diff --git a/litellm/llms/gemini/files/transformation.py b/litellm/llms/gemini/files/transformation.pyindex 44e09af892e..ab2b770cc3a 100644--- a/litellm/llms/gemini/files/transformation.py+++ b/litellm/llms/gemini/files/transformation.py@@ -301,7 +301,7 @@ class GoogleAIStudioFilesHandler(GeminiModelInfo, BaseFilesConfig):url = f"{api_base}/v1beta/{file_name}"# Add API key as header (Google AI Studio uses x-goog-api-key header)- params = {}+ params: dict = {}return url, paramsdiff --git a/litellm/proxy/management_endpoints/key_management_endpoints.py b/litellm/proxy/management_endpoints/key_management_endpoints.pyindex 380e8bddc99..278971a91a5 100644--- a/litellm/proxy/management_endpoints/key_management_endpoints.py+++ b/litellm/proxy/management_endpoints/key_management_endpoints.py@@ -1541,13 +1541,14 @@ async def _process_single_key_update()# Check team member permissions- await TeamMemberPermissionChecks.can_team_member_execute_key_management_endpoint(- user_api_key_dict=user_api_key_dict,- route=KeyManagementRoutes.KEY_UPDATE,- prisma_client=prisma_client,- existing_key_row=existing_key_row,- user_api_key_cache=user_api_key_cache,- )+ if prisma_client is not None:+ await TeamMemberPermissionChecks.can_team_member_execute_key_management_endpoint(+ user_api_key_dict=user_api_key_dict,+ route=KeyManagementRoutes.KEY_UPDATE,+ prisma_client=prisma_client,+ existing_key_row=existing_key_row,+ user_api_key_cache=user_api_key_cache,+ )# Create UpdateKeyRequest from BulkUpdateKeyRequestItemupdate_key_request = UpdateKeyRequest(