From 039debffec007ec93571b5375c82419831a37b8b Mon Sep 17 00:00:00 2001 From: mateo Date: Wed, 23 Sep 2026 01:35:23 +0000 Subject: [PATCH] fix: place lint suppressions on the flagged annotation lines --- litellm/proxy/auth/auth_checks.py | 4 ++-- .../guardrail_hooks/typesafe/typesafe.py | 22 ++++++++++--------- litellm/router_strategy/budget_limiter.py | 5 +++-- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/litellm/proxy/auth/auth_checks.py b/litellm/proxy/auth/auth_checks.py index f601e94ed11..3ddf6b60205 100644 --- a/litellm/proxy/auth/auth_checks.py +++ b/litellm/proxy/auth/auth_checks.py @@ -5229,9 +5229,9 @@ async def _check_team_member_model_access( ): return # no per-member restriction — inherit team-level check - member_allowed_models: Final[list[str]] = ( + member_allowed_models: Final[list[str]] = ( # mutable-ok: allowed_models is a prisma model list consumed read-only loaded_membership.litellm_budget_table.allowed_models - ) # mutable-ok: allowed_models is a prisma model list consumed read-only + ) try: _can_object_call_model( model=model, diff --git a/litellm/proxy/guardrails/guardrail_hooks/typesafe/typesafe.py b/litellm/proxy/guardrails/guardrail_hooks/typesafe/typesafe.py index 7246f6c2d06..3b330190bac 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/typesafe/typesafe.py +++ b/litellm/proxy/guardrails/guardrail_hooks/typesafe/typesafe.py @@ -160,10 +160,10 @@ class TypeSafeGuardrail(CustomGuardrail): max_result_chars_in_state: int | None = None, unreachable_fallback: str | None = None, guardrail_name: str | None = None, - event_hook: GuardrailEventHooks + event_hook: GuardrailEventHooks # mutable-ok: event hook unions accept an ordered list | list[GuardrailEventHooks] | Mode - | None = None, # mutable-ok: event hook unions accept an ordered list + | None = None, default_on: bool = False, async_handler: AsyncHTTPHandler | None = None, ) -> None: @@ -208,8 +208,9 @@ class TypeSafeGuardrail(CustomGuardrail): raise HTTPException(status_code=502, detail={"error": error}) # mutable-ok: FastAPI wants a dict detail def _candidate_exchanges( - self, messages: Sequence[dict[str, object]] - ) -> tuple[tuple[int, ...], ...]: # mutable-ok: message dicts come from the request payload + self, + messages: Sequence[dict[str, object]], # mutable-ok: message dicts come from the request payload + ) -> tuple[tuple[int, ...], ...]: """Completed tool exchanges eligible for evaluation: unprotected, and long enough to be worth a call.""" protected: Final = _protected_indices(messages) candidates: Final = tuple( @@ -224,8 +225,9 @@ class TypeSafeGuardrail(CustomGuardrail): @staticmethod def _exchange_tool_text( - messages: Sequence[dict[str, object]], group: tuple[int, ...] - ) -> str: # mutable-ok: message dicts come from the request payload + messages: Sequence[dict[str, object]], + group: tuple[int, ...], # mutable-ok: message dicts come from the request payload + ) -> str: return "".join( content_to_text(messages[index].get("content")) for index in group[1:] @@ -234,9 +236,9 @@ class TypeSafeGuardrail(CustomGuardrail): def _build_state( self, - messages: Sequence[dict[str, object]], + messages: Sequence[dict[str, object]], # mutable-ok: candidate groups index request message dicts candidates: tuple[tuple[int, ...], ...], # mutable-ok: candidate groups index request message dicts - ) -> dict[str, object]: # mutable-ok: result dict feeds the JSON log record + ) -> dict[str, object]: task: Final = next( ( content_to_text(messages[index].get("content")) @@ -261,8 +263,8 @@ class TypeSafeGuardrail(CustomGuardrail): async def _call_systemone( self, - state: dict[str, object], - question_ids: Sequence[str], # mutable-ok: state dict is the parsed log record + state: dict[str, object], # mutable-ok: state dict is the parsed log record + question_ids: Sequence[str], ) -> _JevSystemOneResponse | None: """Returns the response, or None when the service failed and fail_open applies.""" payload: Final[dict[str, object]] = { # mutable-ok: serialized to JSON by httpx diff --git a/litellm/router_strategy/budget_limiter.py b/litellm/router_strategy/budget_limiter.py index 57e8ddc1c33..029495c4236 100644 --- a/litellm/router_strategy/budget_limiter.py +++ b/litellm/router_strategy/budget_limiter.py @@ -94,8 +94,9 @@ class _LiteLLMParamsDictView: async def _push_increments_to_redis( - redis_cache: RedisCache, queued: list[RedisPipelineIncrementOperation] -) -> None: # mutable-ok: pipeline ops list is built once and consumed by redis + redis_cache: RedisCache, + queued: list[RedisPipelineIncrementOperation], # mutable-ok: pipeline ops list is built once and consumed by redis +) -> None: try: await redis_cache.async_increment_pipeline(increment_list=queued) except Exception as e: # noqa: BLE001 # a budget push failure must not abort the pipeline