fix(mypy): suppress typeddict-item error for tracing_kw expansion

This commit is contained in:
Ishaan Jaffer 2026-02-21 10:00:44 -08:00
parent 08fedb8fd0
commit f4cf2fce55

View file

@ -10,8 +10,19 @@ import json
import os
import re
from datetime import datetime
from typing import (TYPE_CHECKING, Any, AsyncGenerator, Dict, List, Literal,
Optional, Pattern, Tuple, Union, cast)
from typing import (
TYPE_CHECKING,
Any,
AsyncGenerator,
Dict,
List,
Literal,
Optional,
Pattern,
Tuple,
Union,
cast,
)
import yaml
from fastapi import HTTPException
@ -20,22 +31,37 @@ from litellm import Router
from litellm._logging import verbose_proxy_logger
from litellm.integrations.custom_guardrail import CustomGuardrail
from litellm.proxy._types import UserAPIKeyAuth
from litellm.types.utils import (GenericGuardrailAPIInputs, GuardrailStatus,
GuardrailTracingDetail, ModelResponseStream)
from litellm.types.utils import (
GenericGuardrailAPIInputs,
GuardrailStatus,
GuardrailTracingDetail,
ModelResponseStream,
)
if TYPE_CHECKING:
from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj
from litellm.types.guardrails import (BlockedWord, ContentFilterAction,
ContentFilterPattern,
GuardrailEventHooks, Mode)
from litellm.types.guardrails import (
BlockedWord,
ContentFilterAction,
ContentFilterPattern,
GuardrailEventHooks,
Mode,
)
from litellm.types.proxy.guardrails.guardrail_hooks.litellm_content_filter import (
BlockedWordDetection, CategoryKeywordDetection, CompetitorIntentDetection,
CompetitorIntentResult, ContentFilterCategoryConfig,
ContentFilterDetection, PatternDetection)
BlockedWordDetection,
CategoryKeywordDetection,
CompetitorIntentDetection,
CompetitorIntentResult,
ContentFilterCategoryConfig,
ContentFilterDetection,
PatternDetection,
)
from .competitor_intent import (AirlineCompetitorIntentChecker,
BaseCompetitorIntentChecker)
from .competitor_intent import (
AirlineCompetitorIntentChecker,
BaseCompetitorIntentChecker,
)
from .patterns import PATTERN_EXTRA_CONFIG, get_compiled_pattern
MAX_KEYWORD_VALUE_GAP_WORDS = 1
@ -1702,7 +1728,7 @@ class ContentFilterGuardrail(CustomGuardrail):
end_time=datetime.now().timestamp(),
duration=(datetime.now() - start_time).total_seconds(),
masked_entity_count=masked_entity_count,
tracing_detail=GuardrailTracingDetail(**tracing_kw),
tracing_detail=GuardrailTracingDetail(**tracing_kw), # type: ignore[typeddict-item]
)
async def apply_guardrail(
@ -1878,7 +1904,8 @@ class ContentFilterGuardrail(CustomGuardrail):
@staticmethod
def get_config_model():
from litellm.types.proxy.guardrails.guardrail_hooks.litellm_content_filter import \
LitellmContentFilterGuardrailConfigModel
from litellm.types.proxy.guardrails.guardrail_hooks.litellm_content_filter import (
LitellmContentFilterGuardrailConfigModel,
)
return LitellmContentFilterGuardrailConfigModel