mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-20 00:11:50 +00:00
fix(guardrails): satisfy new lint gates for the masking/advisory fix
Parameterize the write-back helper's dict param and suppress the two new lint rules that landed on the base while this branch was in flight: TQ008 (patching an internal collaborator) for two pre-existing tests unrelated to this change, and LIT001 for a param that genuinely needs to mutate the caller's request dict in place.
This commit is contained in:
parent
f8e2725d3f
commit
f1008f2aa7
2 changed files with 4 additions and 4 deletions
|
|
@ -133,7 +133,7 @@ def _pre_masking_scope_indices(
|
|||
|
||||
def _apply_redacted_messages_back_preserving_fields(
|
||||
guardrail: "LakeraAIGuardrail",
|
||||
data: dict,
|
||||
data: dict[str, object], # mutable-ok: writes the redacted result back into the caller's request dict in place
|
||||
redacted_messages: Sequence[Mapping[str, str]],
|
||||
) -> None:
|
||||
"""Write masked content back to ``data["messages"]`` without losing fields
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ class TestSharedFilterMessagesBySkipFlagsUtil:
|
|||
def test_lakera_delegates_to_shared_function(self):
|
||||
guardrail = LakeraAIGuardrail(api_key="test_key", skip_system_message_in_guardrail=True)
|
||||
sentinel = ([USER_MSG], True)
|
||||
with patch(
|
||||
with patch( # test-quality-ok: asserts delegation to the specific shared collaborator, not an HTTP boundary
|
||||
"litellm.proxy.guardrails.guardrail_hooks.lakera_ai_v2.filter_messages_by_skip_flags",
|
||||
return_value=sentinel,
|
||||
) as mock_shared:
|
||||
|
|
@ -417,7 +417,7 @@ class TestPiiMaskingSafetyGuard:
|
|||
}
|
||||
with (
|
||||
patch.object(guardrail, "call_v2_guard", new_callable=AsyncMock) as mock_call,
|
||||
patch(
|
||||
patch( # test-quality-ok: asserts the wholesale write-back path is never reached for this unsafe case
|
||||
"litellm.proxy.guardrails.guardrail_hooks.lakera_ai_v2.apply_redacted_messages_back"
|
||||
) as mock_apply_redacted,
|
||||
):
|
||||
|
|
@ -449,7 +449,7 @@ class TestPiiMaskingSafetyGuard:
|
|||
}
|
||||
with (
|
||||
patch.object(guardrail, "call_v2_guard", new_callable=AsyncMock) as mock_call,
|
||||
patch(
|
||||
patch( # test-quality-ok: asserts the wholesale write-back path is never reached for this unsafe case
|
||||
"litellm.proxy.guardrails.guardrail_hooks.lakera_ai_v2.apply_redacted_messages_back"
|
||||
) as mock_apply_redacted,
|
||||
):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue