From 4db3b41caac2ea5b479465f1d2df3dc6f6a96050 Mon Sep 17 00:00:00 2001 From: mateo <277851410+mateo-berri@users.noreply.github.com> Date: Wed, 4 Nov 2026 07:59:58 +0000 Subject: [PATCH] fix: satisfy media guard type discipline and formatting Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/litellm_core_utils/prompt_templates/common_utils.py | 6 +++++- litellm/proxy/spend_tracking/spend_management_endpoints.py | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/litellm/litellm_core_utils/prompt_templates/common_utils.py b/litellm/litellm_core_utils/prompt_templates/common_utils.py index 496fe566e14..672debcbc7d 100644 --- a/litellm/litellm_core_utils/prompt_templates/common_utils.py +++ b/litellm/litellm_core_utils/prompt_templates/common_utils.py @@ -448,7 +448,11 @@ def _tpm_embedding_leaf(value: object) -> _TPMMediaProjection: return _TPMMediaProjection("" if media else value, media) -def _is_json_array(value: object) -> TypeIs[list[object] | tuple[object, ...]]: # guard-ok: validates JSON arrays +def _is_json_array( + value: object, +) -> TypeIs[ # guard-ok: validates the exact list and tuple types # mutable-ok: JSON input arrays are mutable + list[object] | tuple[object, ...] +]: return isinstance(value, (list, tuple)) diff --git a/litellm/proxy/spend_tracking/spend_management_endpoints.py b/litellm/proxy/spend_tracking/spend_management_endpoints.py index 8790ef42180..fcb9eb4a280 100644 --- a/litellm/proxy/spend_tracking/spend_management_endpoints.py +++ b/litellm/proxy/spend_tracking/spend_management_endpoints.py @@ -1581,9 +1581,7 @@ async def get_global_spend_report( ORDER BY total_cost DESC; """ - db_response = await _query_spend_logs( - prisma_client, sql_query, start_date_obj, end_date_obj, api_key - ) + db_response = await _query_spend_logs(prisma_client, sql_query, start_date_obj, end_date_obj, api_key) return db_response elif internal_user_id is not None: verbose_proxy_logger.debug("Getting /spend for internal_user_id: %s", internal_user_id)