From 99e14efb62d954e0b68285fa8a2fbd1522bf56c5 Mon Sep 17 00:00:00 2001 From: yucheng Date: Sun, 20 Sep 2026 09:09:27 +0000 Subject: [PATCH] refactor(policy_engine): accept any sequence of policy names in condition matching Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/proxy/policy_engine/policy_matcher.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/policy_engine/policy_matcher.py b/litellm/proxy/policy_engine/policy_matcher.py index 2f7fcd23b75..2b54b5dbe41 100644 --- a/litellm/proxy/policy_engine/policy_matcher.py +++ b/litellm/proxy/policy_engine/policy_matcher.py @@ -7,7 +7,7 @@ apply to a given request based on team alias, key alias, and model. Policies are matched via policy_attachments which define WHERE each policy applies. """ -from collections.abc import Callable +from collections.abc import Callable, Sequence from typing import Final from litellm._logging import verbose_proxy_logger @@ -139,7 +139,7 @@ class PolicyMatcher: """Predicate telling whether a policy exists and its condition matches the context.""" return lambda policy_name: bool( PolicyMatcher.get_policies_with_matching_conditions( - policy_names=[policy_name], # mutable-ok: the matcher takes a list + policy_names=(policy_name,), context=context, policies=policies, ) @@ -147,7 +147,7 @@ class PolicyMatcher: @staticmethod def get_policies_with_matching_conditions( - policy_names: list[str], + policy_names: Sequence[str], context: PolicyMatchContext, policies: dict[str, Policy] | None = None, ) -> list[str]: