From 8092a22ddc7c135d7a0f8f15f627ecebfd8ca80a Mon Sep 17 00:00:00 2001 From: lior-k Date: Thu, 30 Apr 2026 20:34:11 +0300 Subject: [PATCH] fix(guardrails/alice_wonderfence): narrow self.guardrail_name to str for mypy Base CustomGuardrail declares guardrail_name as Optional[str]. Our __init__ requires a non-empty value (factory rejects empty), so override the attribute type after super().__init__() to satisfy mypy on dict-key indexing in _stash_resolved. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../guardrail_hooks/alice_wonderfence/alice_wonderfence.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/litellm/proxy/guardrails/guardrail_hooks/alice_wonderfence/alice_wonderfence.py b/litellm/proxy/guardrails/guardrail_hooks/alice_wonderfence/alice_wonderfence.py index 405996085e5..308d46a4942 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/alice_wonderfence/alice_wonderfence.py +++ b/litellm/proxy/guardrails/guardrail_hooks/alice_wonderfence/alice_wonderfence.py @@ -158,6 +158,9 @@ class WonderFenceGuardrail(CustomGuardrail): supported_event_hooks=supported_event_hooks, **kwargs, ) + # Narrow attribute type: base class declares Optional[str], but our + # __init__ requires a non-empty string and the factory rejects empty. + self.guardrail_name: str = guardrail_name key_suffix = f"***{self.api_key[-4:]}" if self.api_key else "" logger.debug(