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

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
mateo 2026-09-04 08:05:04 +00:00
parent b287d915b0
commit 8b37de14b1
7 changed files with 23 additions and 28 deletions

View file

@ -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

View file

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

View file

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

View file

@ -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

View file

@ -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]

View file

@ -78,7 +78,7 @@
"limit": 1
},
"C901": {
"limit": 311
"limit": 309
},
"D419": {
"limit": 6

View file

@ -1,9 +1,9 @@
{
"LIT001": {
"limit": 22328
"limit": 22326
},
"LIT002": {
"limit": 26750
"limit": 26746
},
"LIT003": {
"limit": 261