fix: annotate budget alert claim locals and constants as Final
Some checks failed
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
yucheng 2026-08-10 19:54:15 +00:00
parent dda525049d
commit e01a05472e
2 changed files with 7 additions and 6 deletions

View file

@ -468,8 +468,8 @@ EMAIL_BUDGET_ALERT_TTL: Final = int(os.getenv("EMAIL_BUDGET_ALERT_TTL", 24 * 60
EMAIL_BUDGET_ALERT_MAX_SPEND_ALERT_PERCENTAGE: Final = float(
os.getenv("EMAIL_BUDGET_ALERT_MAX_SPEND_ALERT_PERCENTAGE", 0.8)
) # 80% of max budget
MAX_BUDGET_ALERT_TYPE = "max_budget_alert"
MAX_BUDGET_DEFAULT_ALERT_TYPE = "max_budget_alert_default_threshold"
MAX_BUDGET_ALERT_TYPE: Final = "max_budget_alert"
MAX_BUDGET_DEFAULT_ALERT_TYPE: Final = "max_budget_alert_default_threshold"
############### LLM Provider Constants ###############
### ANTHROPIC CONSTANTS ###
ANTHROPIC_TOKEN_COUNTING_BETA_VERSION = os.getenv("ANTHROPIC_TOKEN_COUNTING_BETA_VERSION", "token-counting-2024-11-01")

View file

@ -17,6 +17,7 @@ from __future__ import annotations
from collections.abc import Mapping
from datetime import datetime, timezone
from typing import Final
from litellm._logging import verbose_proxy_logger
from litellm.proxy.db.exception_handler import PrismaDBExceptionHandler
@ -31,7 +32,7 @@ def get_budget_window(budget_reset_at: datetime | None, max_budget: float | None
lifetime of the key. Including ``max_budget`` means raising or lowering the budget
moves every threshold and re-arms the alerts, which is what an operator expects.
"""
period = budget_reset_at.isoformat() if budget_reset_at is not None else ""
period: Final = budget_reset_at.isoformat() if budget_reset_at is not None else ""
return f"{period}|{max_budget}"
@ -70,7 +71,7 @@ async def claim_budget_alert_slot(
if prisma_client is None:
return True
identity = _claim_identity(token, alert_type, threshold_pct)
identity: Final = _claim_identity(token, alert_type, threshold_pct)
try:
await prisma_client.db.litellm_budgetalertsent.create(
@ -88,7 +89,7 @@ async def claim_budget_alert_slot(
return True
try:
rows_updated = await prisma_client.db.litellm_budgetalertsent.update_many(
rows_updated: Final = await prisma_client.db.litellm_budgetalertsent.update_many(
where={**identity, "budget_window": {"not": budget_window}}, # mutable-ok: prisma query payload
data={ # mutable-ok: prisma query payload
"budget_window": budget_window,
@ -125,7 +126,7 @@ async def release_budget_alert_slot(
if prisma_client is None:
return
identity = _claim_identity(token, alert_type, threshold_pct)
identity: Final = _claim_identity(token, alert_type, threshold_pct)
try:
await prisma_client.db.litellm_budgetalertsent.delete_many(