From cefe7ccd69d0351a3b25de1ed31739b30a647a3a Mon Sep 17 00:00:00 2001 From: shin-bot-litellm Date: Sat, 31 Jan 2026 07:38:52 +0000 Subject: [PATCH] litellm_fix: Fix CI issues - mypy, ruff, and ESLint errors Fixes: - proxy_server.py: Add missing 'timezone' import from datetime - cache_coordinator.py: Fix Protocol method signatures - files/main.py: Add type ignore for wildcard import shadowing - opentelemetry.py: Fix callback_name type (Optional[str] -> str) - common_request_processing.py: Add noqa for PLR0915 (too many statements) - key_management_endpoints.py: Add prisma_client None check - mcp_management_endpoints.py: Add return type annotation to fallback - mcp_server_manager.py: Add return type annotation to fallback - search_endpoints.py: Fix TypedDict access with type ignore - ToolCallCard.tsx: Remove unused ToolOutlined import --- .gitignore | 2 +- litellm/files/main.py | 2 +- litellm/integrations/opentelemetry.py | 2 +- .../proxy/_experimental/mcp_server/mcp_server_manager.py | 4 +++- litellm/proxy/common_request_processing.py | 2 +- litellm/proxy/common_utils/cache_coordinator.py | 4 +++- .../proxy/management_endpoints/key_management_endpoints.py | 6 ++++++ .../proxy/management_endpoints/mcp_management_endpoints.py | 3 ++- litellm/proxy/proxy_server.py | 2 +- litellm/proxy/search_endpoints/endpoints.py | 5 +++-- .../components/view_logs/LogDetailsDrawer/ToolCallCard.tsx | 2 +- 11 files changed, 23 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 32f1b6f8e1f..39186159fe0 100644 --- a/.gitignore +++ b/.gitignore @@ -98,4 +98,4 @@ LAZY_LOADING_IMPROVEMENTS.md **/test-results **/playwright-report **/*.storageState.json -**/coverage \ No newline at end of file +**/coveragelitellm/.mypy_cache/ diff --git a/litellm/files/main.py b/litellm/files/main.py index 93a10dac7a3..1c7696f452a 100644 --- a/litellm/files/main.py +++ b/litellm/files/main.py @@ -34,7 +34,7 @@ from litellm.types.llms.openai import ( HttpxBinaryResponseContent, OpenAIFileObject, ) -from litellm.types.router import * +from litellm.types.router import * # type: ignore[no-redef] from litellm.types.utils import ( OPENAI_COMPATIBLE_BATCH_AND_FILES_PROVIDERS, LlmProviders, diff --git a/litellm/integrations/opentelemetry.py b/litellm/integrations/opentelemetry.py index 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/proxy/_experimental/mcp_server/mcp_server_manager.py b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py index 92fd54e8775..1d1958a9120 100644 --- a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py +++ b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py @@ -67,9 +67,11 @@ from litellm.types.mcp_server.mcp_server_manager import ( try: from mcp.shared.tool_name_validation import SEP_986_URL, validate_tool_name # type: ignore except ImportError: + from typing import Any + SEP_986_URL = "https://github.com/modelcontextprotocol/protocol/blob/main/proposals/0001-tool-name-validation.md" - def validate_tool_name(name: str): + def validate_tool_name(name: str) -> Any: from pydantic import BaseModel class MockResult(BaseModel): diff --git a/litellm/proxy/common_request_processing.py b/litellm/proxy/common_request_processing.py index 136ce696511..d3f01f3bd2c 100644 --- a/litellm/proxy/common_request_processing.py +++ b/litellm/proxy/common_request_processing.py @@ -623,7 +623,7 @@ class ProxyBaseLLMRequestProcessing: return self.data, logging_obj - async def base_process_llm_request( + async def base_process_llm_request( # noqa: PLR0915 self, request: Request, fastapi_response: Response, diff --git a/litellm/proxy/common_utils/cache_coordinator.py b/litellm/proxy/common_utils/cache_coordinator.py index 60d7e3947a6..90caa5b8268 100644 --- a/litellm/proxy/common_utils/cache_coordinator.py +++ b/litellm/proxy/common_utils/cache_coordinator.py @@ -23,9 +23,11 @@ class AsyncCacheProtocol(Protocol): """Protocol for cache backends used by EventDrivenCacheCoordinator.""" async def async_get_cache(self, key: str, **kwargs: Any) -> Any: + """Get value from cache.""" ... - async def async_set_cache(self, key: str, value: Any, **kwargs: Any) -> Any: + async def async_set_cache(self, key: str, value: Any, **kwargs: Any) -> None: + """Set value in cache.""" ... diff --git a/litellm/proxy/management_endpoints/key_management_endpoints.py b/litellm/proxy/management_endpoints/key_management_endpoints.py index 380e8bddc99..44fbeb42419 100644 --- a/litellm/proxy/management_endpoints/key_management_endpoints.py +++ b/litellm/proxy/management_endpoints/key_management_endpoints.py @@ -1531,6 +1531,12 @@ async def _process_single_key_update( Raises: HTTPException: For various validation and permission errors """ + if prisma_client is None: + raise HTTPException( + status_code=500, + detail="Database not connected", + ) + # Validate max_budget _validate_max_budget(key_update_item.max_budget) diff --git a/litellm/proxy/management_endpoints/mcp_management_endpoints.py b/litellm/proxy/management_endpoints/mcp_management_endpoints.py index 83d7f3fde4c..6e897196cff 100644 --- a/litellm/proxy/management_endpoints/mcp_management_endpoints.py +++ b/litellm/proxy/management_endpoints/mcp_management_endpoints.py @@ -59,8 +59,9 @@ if MCP_AVAILABLE: try: from mcp.shared.tool_name_validation import validate_tool_name # type: ignore except ImportError: + from typing import Any - def validate_tool_name(name: str): + def validate_tool_name(name: str) -> Any: from pydantic import BaseModel class MockResult(BaseModel): diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 078ce0edf27..a00f1f605a9 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -11,7 +11,7 @@ import sys import time import traceback import warnings -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone import enum from typing import ( TYPE_CHECKING, diff --git a/litellm/proxy/search_endpoints/endpoints.py b/litellm/proxy/search_endpoints/endpoints.py index c7a3b88c490..50cbd42a06e 100644 --- a/litellm/proxy/search_endpoints/endpoints.py +++ b/litellm/proxy/search_endpoints/endpoints.py @@ -245,8 +245,9 @@ async def list_search_tools( } # Add description if available - if "search_tool_info" in tool and tool["search_tool_info"]: - description = tool["search_tool_info"].get("description") + search_tool_info = tool.get("search_tool_info") # type: ignore[typeddict-item] + if search_tool_info: + description = search_tool_info.get("description") if description: tool_info["description"] = description diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/ToolCallCard.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/ToolCallCard.tsx index 38f2128a3db..c032258717d 100644 --- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/ToolCallCard.tsx +++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/ToolCallCard.tsx @@ -4,7 +4,7 @@ import { useState } from 'react'; import { Button, Typography, message } from 'antd'; -import { CopyOutlined, ToolOutlined } from '@ant-design/icons'; +import { CopyOutlined } from '@ant-design/icons'; import { ToolCall } from './prettyMessagesTypes'; const { Text } = Typography;