From cdcaac75cdfd33de6d929e620969c93fa541abe6 Mon Sep 17 00:00:00 2001 From: Deepanshu Date: Fri, 14 Aug 2026 11:06:09 -0400 Subject: [PATCH] fix(rate-limiting): suppress reportPrivateUsage for established cross-module private-helper reuse Rebasing onto a much-advanced litellm_internal_staging tipped the basedpyright reportPrivateUsage budget: importing _get_parent_otel_span_from_kwargs, _PROXY_MaxParallelRequestsHandler_v3, _get_tags_from_request_kwargs, and _PROXY_TagRateLimiter across module boundaries is the same pattern the sibling dynamic_rate_limiter_v3 hook already uses (its own imports just predate this budget check), so suppress with a reason rather than renaming widely-referenced symbols. --- litellm/litellm_core_utils/litellm_logging.py | 8 ++++++-- litellm/proxy/hooks/tag_rate_limiter.py | 8 +++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index 03d21452513..140449d2e54 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -4477,7 +4477,9 @@ def _init_custom_logger_compatible_class( _in_memory_loggers.append(dynamic_rate_limiter_obj_v3) return dynamic_rate_limiter_obj_v3 elif logging_integration == "tag_rate_limiter": - from litellm.proxy.hooks.tag_rate_limiter import _PROXY_TagRateLimiter + from litellm.proxy.hooks.tag_rate_limiter import ( + _PROXY_TagRateLimiter, # pyright: ignore[reportPrivateUsage] # resolved by name like every other opt-in callback here + ) for callback in _in_memory_loggers: if isinstance(callback, _PROXY_TagRateLimiter): @@ -4933,7 +4935,9 @@ def get_custom_logger_compatible_class( return callback elif logging_integration == "tag_rate_limiter": - from litellm.proxy.hooks.tag_rate_limiter import _PROXY_TagRateLimiter + from litellm.proxy.hooks.tag_rate_limiter import ( + _PROXY_TagRateLimiter, # pyright: ignore[reportPrivateUsage] # resolved by name like every other opt-in callback here + ) for callback in _in_memory_loggers: if isinstance(callback, _PROXY_TagRateLimiter): diff --git a/litellm/proxy/hooks/tag_rate_limiter.py b/litellm/proxy/hooks/tag_rate_limiter.py index 993893d452a..db88d7438fc 100644 --- a/litellm/proxy/hooks/tag_rate_limiter.py +++ b/litellm/proxy/hooks/tag_rate_limiter.py @@ -14,16 +14,18 @@ from litellm.caching.dual_cache import DualCache from litellm.exceptions import RateLimitType from litellm.integrations.custom_logger import CustomLogger from litellm.litellm_core_utils.core_helpers import ( - _get_parent_otel_span_from_kwargs, + _get_parent_otel_span_from_kwargs, # pyright: ignore[reportPrivateUsage] # reused across module boundaries, matching dynamic_rate_limiter_v3's identical import get_metadata_variable_name_from_kwargs, ) from litellm.proxy.common_utils.proxy_rate_limit_error import ProxyRateLimitError from litellm.proxy.hooks.parallel_request_limiter_v3 import ( - _PROXY_MaxParallelRequestsHandler_v3, + _PROXY_MaxParallelRequestsHandler_v3, # pyright: ignore[reportPrivateUsage] # this hook explicitly reuses its Redis/TTL-preserving increment machinery, see module docstring ) from litellm.proxy.utils import InternalUsageCache from litellm.router import Router -from litellm.router_strategy.tag_based_routing import _get_tags_from_request_kwargs +from litellm.router_strategy.tag_based_routing import ( + _get_tags_from_request_kwargs, # pyright: ignore[reportPrivateUsage] # reused across module boundaries, matching dynamic_rate_limiter_v3's identical import +) from litellm.types.caching import RedisPipelineIncrementOperation from litellm.types.llms.openai import AllMessageValues from litellm.types.router import TagRateLimitEntry, TagRateLimits