From 717a32c9c9820a52ecaae9d9255e62dcf5c67db1 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 28 Feb 2026 04:39:55 +0000 Subject: [PATCH] fix(mypy): resolve type errors in public_endpoints, user_api_key_auth, common_utils, transformation - public_endpoints.py: fix _cached_endpoints type annotation - user_api_key_auth.py: accept Optional[str] for end_user_id parameter - common_utils.py: add NewProjectRequest/UpdateProjectRequest to Union type - transformation.py: add ChatCompletionRedactedThinkingBlock and list[Any] to content type Co-authored-by: Ishaan Jaff --- .../litellm_responses_transformation/transformation.py | 4 +++- litellm/proxy/auth/user_api_key_auth.py | 2 +- litellm/proxy/management_endpoints/common_utils.py | 3 +++ litellm/proxy/public_endpoints/public_endpoints.py | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/litellm/completion_extras/litellm_responses_transformation/transformation.py b/litellm/completion_extras/litellm_responses_transformation/transformation.py index 35fc93bbeb0..5d1d6d412dd 100644 --- a/litellm/completion_extras/litellm_responses_transformation/transformation.py +++ b/litellm/completion_extras/litellm_responses_transformation/transformation.py @@ -49,6 +49,7 @@ if TYPE_CHECKING: ALL_RESPONSES_API_TOOL_PARAMS, AllMessageValues, ChatCompletionImageObject, + ChatCompletionRedactedThinkingBlock, ChatCompletionThinkingBlock, OpenAIMessageContentListBlock, ) @@ -579,7 +580,8 @@ class LiteLLMResponsesTransformationHandler(CompletionTransformationBridge): content: Optional[ Union[ str, - Iterable[Union["OpenAIMessageContentListBlock", "ChatCompletionThinkingBlock"]], + List[Any], + Iterable[Union["OpenAIMessageContentListBlock", "ChatCompletionThinkingBlock", "ChatCompletionRedactedThinkingBlock"]], ] ], role: str, diff --git a/litellm/proxy/auth/user_api_key_auth.py b/litellm/proxy/auth/user_api_key_auth.py index 8ad3b83c043..c4ffc1a60f1 100644 --- a/litellm/proxy/auth/user_api_key_auth.py +++ b/litellm/proxy/auth/user_api_key_auth.py @@ -164,7 +164,7 @@ def _get_bearer_token( def _apply_budget_limits_to_end_user_params( end_user_params: dict, budget_info: LiteLLM_BudgetTable, - end_user_id: str, + end_user_id: Optional[str], ) -> None: """ Helper function to apply budget limits to end user parameters. diff --git a/litellm/proxy/management_endpoints/common_utils.py b/litellm/proxy/management_endpoints/common_utils.py index 999c53e6b82..76a11c4dfd4 100644 --- a/litellm/proxy/management_endpoints/common_utils.py +++ b/litellm/proxy/management_endpoints/common_utils.py @@ -16,6 +16,7 @@ from litellm.proxy._types import ( from litellm.proxy.utils import _premium_user_check if TYPE_CHECKING: + from litellm.proxy._types import NewProjectRequest, UpdateProjectRequest from litellm.proxy.utils import PrismaClient, ProxyLogging @@ -283,6 +284,8 @@ def _set_object_metadata_field( KeyRequestBase, LiteLLM_OrganizationTable, LiteLLM_ProjectTable, + "NewProjectRequest", + "UpdateProjectRequest", ], field_name: str, value: Any, diff --git a/litellm/proxy/public_endpoints/public_endpoints.py b/litellm/proxy/public_endpoints/public_endpoints.py index ac5d9126145..09fc6477829 100644 --- a/litellm/proxy/public_endpoints/public_endpoints.py +++ b/litellm/proxy/public_endpoints/public_endpoints.py @@ -76,7 +76,7 @@ _ENDPOINT_METADATA: Dict[str, Dict[str, str]] = { _SLUG_SUFFIX_RE = re.compile(r"\s*\(`[^`]+`\)\s*$") # Loaded once on first request; never invalidated (local file, no TTL needed). -_cached_endpoints: Optional[List[Dict[str, Any]]] = None +_cached_endpoints: Optional[SupportedEndpointsResponse] = None def _clean_display_name(raw: str) -> str: