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
style(proxy): add Final type annotations to enduser budget reset variables
amasen023623aecc6419
diff --git a/litellm/proxy/common_utils/reset_budget_job.py b/litellm/proxy/common_utils/reset_budget_job.pyindex 12ba75aea24..4fb544cbb15 100644--- a/litellm/proxy/common_utils/reset_budget_job.py+++ b/litellm/proxy/common_utils/reset_budget_job.py@@ -189,7 +189,7 @@ def _enduser_cache_keys(row: _EndUserRow) -> tuple[str, ...]:def _enduser_carried_spend(row: _EndUserRow, caps: Mapping[str, float]) -> float:if not caps:return 0.0- effective_budget_id = row.budget_id or litellm.max_end_user_budget_id+ effective_budget_id: Final[str | None] = row.budget_id or litellm.max_end_user_budget_idreturn _carried_spend(row.spend, caps.get(effective_budget_id) if effective_budget_id is not None else None)diff --git a/tests/test_litellm/proxy/common_utils/test_reset_budget_job.py b/tests/test_litellm/proxy/common_utils/test_reset_budget_job.pyindex e6bbfd8c7d4..bc9926a314f 100644--- a/tests/test_litellm/proxy/common_utils/test_reset_budget_job.py+++ b/tests/test_litellm/proxy/common_utils/test_reset_budget_job.py@@ -4,7 +4,7 @@ import sysimport typesfrom datetime import datetime, timedelta, timezonefrom datetime import time as dt_time-from typing import Any, Dict, List+from typing import Any, Dict, Final, Listfrom unittest.mock import AsyncMock, MagicMockimport httpx@@ -1497,10 +1497,10 @@ def test_budget_table_reset_invalidates_every_tag_not_just_the_first(reset_budgedef test_budget_table_reset_invalidates_enduser_counter_and_cache(reset_budget_job, mock_prisma_client, monkeypatch):"""When an end user's budget resets, its Redis spend counter is zeroed and its management cache is evicted."""- counter_cache = _make_counter_invalidation_job(monkeypatch)- budget = _budget_row(budget_id="budget-1")+ counter_cache: Final = _make_counter_invalidation_job(monkeypatch)+ budget: Final = _budget_row(budget_id="budget-1")mock_prisma_client.data["budget"] = [budget]- test_enduser = type(+ test_enduser: Final = type("LiteLLM_EndUserTable",(),{@@ -1516,7 +1516,7 @@ def test_budget_table_reset_invalidates_enduser_counter_and_cache(reset_budget_jcounter_cache.in_memory_cache.set_cache.assert_any_call(key="spend:end_user:customer-42", value=0.0, ttl=60)counter_cache.redis_cache.async_set_cache.assert_any_await(key="spend:end_user:customer-42", value=0.0, ttl=60)- deleted = {call.kwargs.get("key") for call in counter_cache.user_api_key_cache.async_delete_cache.await_args_list}+ deleted: Final = {call.kwargs.get("key") for call in counter_cache.user_api_key_cache.async_delete_cache.await_args_list}assert "end_user_id:customer-42" in deleted