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]

fix(caching): clear strict-lint budget breaches in re-landed closer code

mateo-berriebc31f7e066e
diff --git a/litellm/caching/evicted_client_closer.py b/litellm/caching/evicted_client_closer.py
index c895669be2b..eee7e2ea289 100644
--- a/litellm/caching/evicted_client_closer.py
+++ b/litellm/caching/evicted_client_closer.py
@@ -34,6 +34,7 @@ alive anything the collector would have reclaimed first.
"""
import asyncio
+import contextlib
import inspect
import threading
import time
@@ -146,10 +147,8 @@ def _has_connection_in_flight(client: object) -> bool:
async def _close_quietly(closing: Awaitable[object]) -> None:
- try:
+ with contextlib.suppress(Exception):
await closing
- except Exception: # noqa: BLE001 - a discarded client's close must never surface to callers
- pass
class EvictedClientCloser:
diff --git a/litellm/caching/llm_caching_handler.py b/litellm/caching/llm_caching_handler.py
index 6fa5963c99b..a89e43b78b4 100644
--- a/litellm/caching/llm_caching_handler.py
+++ b/litellm/caching/llm_caching_handler.py
@@ -29,7 +29,7 @@ class LLMClientCache(InMemoryCache):
default_ttl: int | None = 600,
max_size_per_item: int | None = 1024,
evicted_client_closer: EvictedClientCloser | None = None,
- ):
+ ) -> None:
super().__init__(
max_size_in_memory=max_size_in_memory,
default_ttl=default_ttl,