From 69e51f40fed510d32e0214d0dfc1327469936e9d Mon Sep 17 00:00:00 2001 From: Kylinny <64238008+Kylinny@users.noreply.github.com> Date: Wed, 14 Oct 2026 11:56:32 +0000 Subject: [PATCH] chore(router): add type-discipline suppression reasons for tool-protocol filter The type-discipline gate counts LIT001/LIT010 against the merge-base ceiling; this change adds the sanctioned suppression markers with reasons instead of new violations: - LIT001 (mutable collection in annotation): the filter's signatures mirror the router's list-or-dict candidate types; functions only read the inputs and build new lists, never mutating them. - LIT010 (assignment without Final): the two new filter call sites rebind the pipeline variable, matching the established progressive narrowing pattern used by every neighboring filter in these methods. No behavior change; comment-only. Signed-off-by: Kylinny Signed-off-by: Kylinny <64238008+Kylinny@users.noreply.github.com> --- litellm/router.py | 4 ++-- litellm/router_utils/common_utils.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/litellm/router.py b/litellm/router.py index 082b4a6179a..1e644433ef2 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -15039,7 +15039,7 @@ class Router: model, ) ) - healthy_deployments = filter_tool_protocol_deployments( + healthy_deployments = filter_tool_protocol_deployments( # rebind-ok: progressive narrowing of the candidate list through the router filter pipeline; rebinding is the established pattern in this function healthy_deployments=healthy_deployments, request_kwargs=request_kwargs, ) @@ -16355,7 +16355,7 @@ class Router: self._filter_blocked_deployments(healthy_deployments), routing_kwargs ) - healthy_deployments = filter_tool_protocol_deployments( + healthy_deployments = filter_tool_protocol_deployments( # rebind-ok: progressive narrowing of the candidate list through the router filter pipeline; rebinding is the established pattern in this function healthy_deployments=healthy_deployments, request_kwargs=request_kwargs, ) diff --git a/litellm/router_utils/common_utils.py b/litellm/router_utils/common_utils.py index 53b385fc302..03113c13f06 100644 --- a/litellm/router_utils/common_utils.py +++ b/litellm/router_utils/common_utils.py @@ -407,7 +407,7 @@ _OPENAI_NATIVE_PROTOCOL_PROVIDERS: Final = frozenset( ) -def _deployment_speaks_openai_protocol(deployment: dict) -> bool: +def _deployment_speaks_openai_protocol(deployment: dict) -> bool: # mutable-ok: read-only access; router passes plain deployment dicts and this helper never mutates them litellm_params: Final = deployment.get("litellm_params") or {} provider: Final = provider_for_generic_call(litellm_params) if provider is None: @@ -416,9 +416,9 @@ def _deployment_speaks_openai_protocol(deployment: dict) -> bool: def filter_tool_protocol_deployments( - healthy_deployments: list[dict] | dict, - request_kwargs: dict | None = None, -) -> list[dict] | dict: + healthy_deployments: list[dict] | dict, # mutable-ok: mirrors the router list-or-dict candidate type; the filter builds new lists and never mutates inputs + request_kwargs: dict | None = None, # mutable-ok: matches the OptionalParams dict type used across the router; read-only in this function +) -> list[dict] | dict: # mutable-ok: returns the input or a narrowed new list; same list-or-dict contract as the router pipeline """ Keep only OpenAI-protocol deployments for OpenAI-format tool-calling requests.