Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test(guardrails): type the native lifecycle logging_only test double

joshua-berri49b2d71057d4
diff --git a/tests/test_litellm/integrations/test_custom_guardrail.py b/tests/test_litellm/integrations/test_custom_guardrail.py
index 8095be3c0de..bb29bfed283 100644
--- a/tests/test_litellm/integrations/test_custom_guardrail.py
+++ b/tests/test_litellm/integrations/test_custom_guardrail.py
@@ -2902,9 +2902,15 @@ class _NativeLifecycleLoggingGuardrail(CustomGuardrail):
guardrail_name="native-logging-guardrail",
event_hook=GuardrailEventHooks.logging_only,
)
- self.calls: list = []
+ self.calls: list[tuple[Literal["request", "response"], list[str]]] = []
- async def apply_guardrail(self, inputs, request_data, input_type, logging_obj=None):
+ async def apply_guardrail(
+ self,
+ inputs: GenericGuardrailAPIInputs,
+ request_data: dict[str, object],
+ input_type: Literal["request", "response"],
+ logging_obj: "LiteLLMLoggingObj | None" = None,
+ ) -> GenericGuardrailAPIInputs:
self.calls.append((input_type, list(inputs.get("texts") or [])))
return inputs