From 43654422f51212a9ba77e0733e1769e6f121527d Mon Sep 17 00:00:00 2001 From: Deepanshu Date: Mon, 17 Aug 2026 15:13:43 -0400 Subject: [PATCH] style(rate-limiting): shrink a LIT001 annotation the base's ratcheted-down budget now flags The base branch's type-discipline ceiling tightened from unrelated merged PRs, newly flagging an annotated dict declaration ruff format had to wrap across lines. Added a _PartitionOperations type alias so the declaration fits on one line the gate can associate its justification comment with. --- litellm/proxy/hooks/tag_rate_limiter.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/hooks/tag_rate_limiter.py b/litellm/proxy/hooks/tag_rate_limiter.py index 5c05caca04c..6faa4bcb7e7 100644 --- a/litellm/proxy/hooks/tag_rate_limiter.py +++ b/litellm/proxy/hooks/tag_rate_limiter.py @@ -670,6 +670,10 @@ def _resolve_max_in_memory_cache_size() -> int | None: # keeps _PROXY_TagRateLimiter._partitions from leaking a fresh partition # every time _TagRateLimitIndex rebuilds and reconstructs `_ConfiguredLimit`s. _PartitionKey: TypeAlias = tuple[str, str, float, int, bool, int] | None +# Grouping type for async_log_success_event's per-partition tokens/dollars +# pipeline dispatch -- named only so the declaration fits on one line; see +# that method for why the grouping is needed. +_PartitionOperations: TypeAlias = dict[_PartitionKey, list[RedisPipelineIncrementOperation]] def _partition_key(entry: TagRateLimitEntry) -> _PartitionKey: @@ -1152,8 +1156,7 @@ class _PROXY_TagRateLimiter( # pyright: ignore[reportUnusedClass] # only refer # more than one partition, and each partition owns its own v3 # handler (see _build_partition), so each group's operations are # pipelined through that partition's own handler. - # mutable-ok: groups operations by cache partition before dispatching each group's pipeline call - operations_by_partition: Final[dict[_PartitionKey, list[RedisPipelineIncrementOperation]]] = {} + operations_by_partition: Final[_PartitionOperations] = {} # mutable-ok: see comment above for configured_limit, operation in operation_by_limit: operations_by_partition.setdefault(_partition_key(configured_limit.entry), []).append( operation