Skip to content

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]

refactor: drop fresh Any annotations and suppressions from admission control, spend summary, and dual cache

mateo8b37de14b1e9
diff --git a/basedpyright-code-budget.json b/basedpyright-code-budget.json
index 0a29e7eae7e..91e32bc1789 100644
--- a/basedpyright-code-budget.json
+++ b/basedpyright-code-budget.json
@@ -1,6 +1,6 @@
{
"reportAny": {
- "limit": 14074
+ "limit": 14070
},
"reportArgumentType": {
"limit": 2206
@@ -24,7 +24,7 @@
"limit": 19
},
"reportExplicitAny": {
- "limit": 4123
+ "limit": 4117
},
"reportFunctionMemberAccess": {
"limit": 7
@@ -108,7 +108,7 @@
"limit": 38311
},
"reportUnknownParameterType": {
- "limit": 19624
+ "limit": 19623
},
"reportUnknownVariableType": {
"limit": 29847
diff --git a/litellm/caching/dual_cache.py b/litellm/caching/dual_cache.py
index df67ba08416..ec17cc1d809 100644
--- a/litellm/caching/dual_cache.py
+++ b/litellm/caching/dual_cache.py
@@ -257,7 +257,7 @@ class DualCache(BaseCache):
self,
current_time: float,
keys: list[str],
- result: Sequence[Any],
+ result: Sequence[object],
) -> tuple[list[str], dict[str, float | None]]:
"""
Atomically choose keys to fetch from Redis and reserve their access time.
diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py
index 17a19f05fa3..925c7416b19 100644
--- a/litellm/litellm_core_utils/litellm_logging.py
+++ b/litellm/litellm_core_utils/litellm_logging.py
@@ -3815,7 +3815,7 @@ class Logging(LiteLLMLoggingBaseClass):
def record_streamed_anthropic_message_id(self, message_id: str) -> None:
self.streamed_anthropic_message_id = message_id
- def _anthropic_messages_logged_response(self, result: Any) -> ModelResponse:
+ def _anthropic_messages_logged_response(self, result: object) -> ModelResponse:
"""
The ModelResponse a /v1/messages spend_logs row is built from.
diff --git a/litellm/proxy/middleware/admission_control_middleware.py b/litellm/proxy/middleware/admission_control_middleware.py
index aa62ef9e3bf..e347428be83 100644
--- a/litellm/proxy/middleware/admission_control_middleware.py
+++ b/litellm/proxy/middleware/admission_control_middleware.py
@@ -32,9 +32,6 @@ class AdmissionControlSettings:
queue_timeout_seconds: float
-AdmissionControlSettingsGetter: TypeAlias = Callable[[], AdmissionControlSettings | None] # mutable-ok: Callable params
-
-
@dataclass(frozen=True, slots=True)
class AdmissionControlStats:
admitted: int
@@ -66,13 +63,10 @@ class AdmissionControlMetrics:
rejected_counter: _Counter
-AdmissionControlMetricsFactory: TypeAlias = Callable[[], AdmissionControlMetrics | None] # mutable-ok: Callable params
-
-
class AdmissionControlState:
"""Per-process admission counters and the in-flight semaphore shared by one worker's requests."""
- def __init__(self, metrics_factory: AdmissionControlMetricsFactory) -> None:
+ def __init__(self, metrics_factory: Callable[[], AdmissionControlMetrics | None]) -> None:
self._metrics_factory = metrics_factory
self._metrics: AdmissionControlMetrics | None = None
self._metrics_init_attempted = False
@@ -140,7 +134,7 @@ class AdmissionControlMiddleware:
def __init__(
self,
app: ASGIApp,
- get_settings: AdmissionControlSettingsGetter,
+ get_settings: Callable[[], AdmissionControlSettings | None],
state: AdmissionControlState,
) -> None:
self.app = app
diff --git a/litellm/proxy/spend_tracking/spend_management_endpoints.py b/litellm/proxy/spend_tracking/spend_management_endpoints.py
index dff100bdea7..f8831ca4152 100644
--- a/litellm/proxy/spend_tracking/spend_management_endpoints.py
+++ b/litellm/proxy/spend_tracking/spend_management_endpoints.py
@@ -3365,23 +3365,24 @@ async def view_spend_logs(
)
sql_query, params = summary_sql_and_params
rows: Final[Sequence[_SpendDailySummaryRow]] = await _query_raw(prisma_client, sql_query, *params)
- if len(rows) == 0:
- return [] # pyright: ignore[reportUnknownVariableType] # empty summary has no element type
-
summary_items: Final = tuple(
_daily_summary_item(date.fromisoformat(day), tuple(day_rows))
for day, day_rows in groupby(rows, key=lambda row: row["day"])
)
- final_date: Final = date.fromisoformat(rows[-1]["day"])
+ final_date: Final = date.fromisoformat(rows[-1]["day"]) if len(rows) > 0 else None
end_date_date: Final = end_date_obj.date()
- padding: Final[tuple[Mapping[str, object], ...]] = tuple(
- {
- "startTime": final_date + timedelta(days=offset),
- "spend": 0,
- "users": {},
- "models": {},
- }
- for offset in range(1, (end_date_date - final_date).days + 1)
+ padding: Final[tuple[Mapping[str, object], ...]] = (
+ ()
+ if final_date is None
+ else tuple(
+ {
+ "startTime": final_date + timedelta(days=offset),
+ "spend": 0,
+ "users": {},
+ "models": {},
+ }
+ for offset in range(1, (end_date_date - final_date).days + 1)
+ )
)
return [*summary_items, *padding]
diff --git a/ruff-strict-budget.json b/ruff-strict-budget.json
index 8763318b4eb..f54f31d182d 100644
--- a/ruff-strict-budget.json
+++ b/ruff-strict-budget.json
@@ -78,7 +78,7 @@
"limit": 1
},
"C901": {
- "limit": 311
+ "limit": 309
},
"D419": {
"limit": 6
diff --git a/type-discipline-budget.json b/type-discipline-budget.json
index ab1a793e09d..3b56aa11d02 100644
--- a/type-discipline-budget.json
+++ b/type-discipline-budget.json
@@ -1,9 +1,9 @@
{
"LIT001": {
- "limit": 22328
+ "limit": 22326
},
"LIT002": {
- "limit": 26750
+ "limit": 26746
},
"LIT003": {
"limit": 261