fix linting + QA checks

This commit is contained in:
Ishaan Jaffer 2026-01-22 18:39:56 -08:00
parent eb422f6985
commit 939c326366
6 changed files with 7 additions and 63 deletions

View file

@ -185,9 +185,9 @@ async def get_policy_info(
policy_name=policy_name,
inherit=policy.inherit,
scope=PolicyScopeResponse(
teams=policy.scope.get_teams(),
keys=policy.scope.get_keys(),
models=policy.scope.get_models(),
teams=[],
keys=[],
models=[],
),
guardrails=PolicyGuardrailsResponse(
add=policy.guardrails.get_add(),
@ -245,9 +245,7 @@ async def test_policy_matching(
policies = registry.get_all_policies()
# Get matching policies
matching_policy_names = PolicyMatcher.get_matching_policies(
policies=policies, context=context
)
matching_policy_names = PolicyMatcher.get_matching_policies(context=context)
# Resolve guardrails
resolved_guardrails = PolicyResolver.resolve_guardrails_for_context(

View file

@ -11,7 +11,6 @@ from litellm._logging import verbose_proxy_logger
from litellm.types.proxy.policy_engine import (
PolicyAttachment,
PolicyMatchContext,
PolicyScope,
)

View file

@ -13,7 +13,6 @@ from litellm._logging import verbose_proxy_logger
from litellm.types.proxy.policy_engine import (
Policy,
PolicyCondition,
PolicyConfig,
PolicyGuardrails,
)

View file

@ -8,7 +8,7 @@ Handles:
- Combining guardrails from multiple matching policies
"""
from typing import Any, Dict, List, Optional, Set
from typing import Dict, List, Optional, Set
from litellm._logging import verbose_proxy_logger
from litellm.types.proxy.policy_engine import (

View file

@ -12,7 +12,6 @@ Validates:
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set
from litellm._logging import verbose_proxy_logger
from litellm.proxy.auth.route_checks import RouteChecks
from litellm.types.proxy.policy_engine import (
Policy,
PolicyValidationError,
@ -267,53 +266,8 @@ class PolicyValidator:
)
)
# Validate team aliases (non-wildcard only, query per alias)
if validate_db and self.prisma_client:
for team_pattern in policy.scope.get_teams():
if not self.is_wildcard_pattern(team_pattern):
exists = await self.check_team_alias_exists(team_alias=team_pattern)
if not exists:
warnings.append(
PolicyValidationError(
policy_name=policy_name,
error_type=PolicyValidationErrorType.INVALID_TEAM,
message=f"Team alias '{team_pattern}' not found in database",
field="scope.teams",
value=team_pattern,
)
)
# Validate key aliases (non-wildcard only, query per alias)
if validate_db and self.prisma_client:
for key_pattern in policy.scope.get_keys():
if not self.is_wildcard_pattern(key_pattern):
exists = await self.check_key_alias_exists(key_alias=key_pattern)
if not exists:
warnings.append(
PolicyValidationError(
policy_name=policy_name,
error_type=PolicyValidationErrorType.INVALID_KEY,
message=f"Key alias '{key_pattern}' not found in database",
field="scope.keys",
value=key_pattern,
)
)
# Validate models (non-wildcard only, check against router)
if self.llm_router:
for model_pattern in policy.scope.get_models():
if not self.is_wildcard_pattern(model_pattern):
exists = self.check_model_exists(model=model_pattern)
if not exists:
warnings.append(
PolicyValidationError(
policy_name=policy_name,
error_type=PolicyValidationErrorType.INVALID_MODEL,
message=f"Model '{model_pattern}' not found in router",
field="scope.models",
value=model_pattern,
)
)
# Note: Team, key, and model validation is done via policy_attachments
# Policies no longer have scope - attachments define where policies apply
# Validate inheritance
inheritance_errors = self._validate_inheritance_chain(

View file

@ -2869,12 +2869,6 @@ class ProxyConfig:
verbose_proxy_logger.info(f"Policy engine: found {len(policies_config)} policies in config")
# Create validator with router for model validation
validator = PolicyValidator(
prisma_client=prisma_client,
llm_router=llm_router,
)
# Initialize policies
await init_policies(
policies_config=policies_config,