From 7e9df3c19ac79640772648d7821ad2004196578e Mon Sep 17 00:00:00 2001 From: Abhyuday Date: Thu, 5 Nov 2026 09:27:18 -0500 Subject: [PATCH] fix(proxy): stay within the ruff strict-rule TRY300 budget Move the success return of the Redis spend counter delete retry loop into the try's else branch. Co-Authored-By: Claude Opus 5.5 --- litellm/proxy/common_utils/reset_budget_job.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/common_utils/reset_budget_job.py b/litellm/proxy/common_utils/reset_budget_job.py index aca21705124..e382a03ecf6 100644 --- a/litellm/proxy/common_utils/reset_budget_job.py +++ b/litellm/proxy/common_utils/reset_budget_job.py @@ -630,7 +630,6 @@ class ResetBudgetJob: for attempt in range(RESET_BUDGET_SPEND_COUNTER_RESET_MAX_ATTEMPTS): try: await redis_cache.async_delete_cache(key=counter_key) - return except Exception as redis_err: # noqa: BLE001 # any Redis failure here is worth a retry, not just specific ones verbose_proxy_logger.warning( "Attempt %d/%d to reset spend counter %s in Redis failed: %s", @@ -641,6 +640,8 @@ class ResetBudgetJob: ) if attempt < RESET_BUDGET_SPEND_COUNTER_RESET_MAX_ATTEMPTS - 1: await asyncio.sleep(RESET_BUDGET_SPEND_COUNTER_RESET_RETRY_DELAY_SECONDS) + else: + return verbose_proxy_logger.error( "Failed to reset spend counter %s in Redis after %d attempts; budget may be " "over-enforced until the counter expires.",