mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
refactor(test): move inline imports to module level in test_custom_guardrail
Per project style guide (CLAUDE.md): imports must be at module level. Moved CustomGuardrail, log_guardrail_information, GuardrailEventHooks, Mode, and GenericGuardrailAPIInputs from inline test method imports to the top of the file. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d1760fe474
commit
479ac6ea95
1 changed files with 3 additions and 16 deletions
|
|
@ -2,9 +2,10 @@ from unittest.mock import AsyncMock
|
|||
|
||||
import pytest
|
||||
|
||||
from litellm.integrations.custom_guardrail import CustomGuardrail
|
||||
from litellm.integrations.custom_guardrail import CustomGuardrail, log_guardrail_information
|
||||
from litellm.proxy._types import CallTypes, UserAPIKeyAuth
|
||||
from litellm.types.utils import GuardrailTracingDetail
|
||||
from litellm.types.guardrails import GuardrailEventHooks, Mode
|
||||
from litellm.types.utils import GenericGuardrailAPIInputs, GuardrailTracingDetail
|
||||
|
||||
|
||||
class TestCustomGuardrailDeploymentHook:
|
||||
|
|
@ -949,13 +950,6 @@ class TestLogGuardrailInformationApplyGuardrailEventType:
|
|||
guardrail_mode should be GuardrailEventHooks.pre_call (a string), not
|
||||
a GuardrailMode dict.
|
||||
"""
|
||||
from litellm.integrations.custom_guardrail import (
|
||||
CustomGuardrail,
|
||||
log_guardrail_information,
|
||||
)
|
||||
from litellm.types.guardrails import GuardrailEventHooks, Mode
|
||||
from litellm.types.utils import GenericGuardrailAPIInputs
|
||||
|
||||
# Build a Mode object (tags-based routing), which is what custom-code
|
||||
# guardrails use. Without the fix, this becomes a GuardrailMode dict
|
||||
# in the logged data, triggering .replace is not a function in the UI.
|
||||
|
|
@ -997,13 +991,6 @@ class TestLogGuardrailInformationApplyGuardrailEventType:
|
|||
When apply_guardrail is called with input_type='response', the logged
|
||||
guardrail_mode should be GuardrailEventHooks.post_call (a string).
|
||||
"""
|
||||
from litellm.integrations.custom_guardrail import (
|
||||
CustomGuardrail,
|
||||
log_guardrail_information,
|
||||
)
|
||||
from litellm.types.guardrails import GuardrailEventHooks, Mode
|
||||
from litellm.types.utils import GenericGuardrailAPIInputs
|
||||
|
||||
mode = Mode(tags={}, default="post_call")
|
||||
|
||||
class _TestGuardrail(CustomGuardrail):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue