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 <noreply@anthropic.com>
This commit is contained in:
Abhyuday 2026-11-05 09:27:18 -05:00
parent d36ae0f9bf
commit 7e9df3c19a

View file

@ -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.",