mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
fix(ci): resolve 5 CI failures — MyPy errors, presidio test, and JWT test mocks
1. MyPy: Add type: ignore[union-attr] for entity_type.value in presidio.py:555 2. MyPy: Add type: ignore[attr-defined] for ModelResponse.usage in presidio.py:1138 3. MyPy: Add type: ignore[attr-defined] for async_health_check in _health_endpoints.py:303 4. Fix test_output_parsing: pass pii_tokens in request data dict so _process_response_for_pii can find them for de-anonymization 5. Fix JWT OIDC tests: add missing mock_response.status_code = 200 so _resolve_jwks_url doesn't raise HTTP error before reaching test logic Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
This commit is contained in:
parent
93e08a6509
commit
4d295ee620
4 changed files with 9 additions and 5 deletions
|
|
@ -552,7 +552,7 @@ class _OPTIONAL_PresidioPIIMasking(CustomGuardrail):
|
|||
entity_type = item.get("entity_type")
|
||||
|
||||
str_entity_type = str(
|
||||
entity_type.value if hasattr(entity_type, "value") else entity_type
|
||||
entity_type.value if hasattr(entity_type, "value") else entity_type # type: ignore[union-attr]
|
||||
)
|
||||
if entity_type and str_entity_type in deny_list_strings:
|
||||
continue
|
||||
|
|
@ -1135,7 +1135,7 @@ class _OPTIONAL_PresidioPIIMasking(CustomGuardrail):
|
|||
) and remaining_chunks:
|
||||
last_chunk = remaining_chunks[-1]
|
||||
if hasattr(last_chunk, "usage") and last_chunk.usage:
|
||||
assembled_model_response.usage = last_chunk.usage
|
||||
assembled_model_response.usage = last_chunk.usage # type: ignore[attr-defined]
|
||||
|
||||
# Apply PII unmasking to assembled content (unmasking tokens back to original text)
|
||||
await self._process_response_for_pii(
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ async def health_services_endpoint( # noqa: PLR0915
|
|||
datadog_metrics_logger = DatadogMetricsLogger(
|
||||
start_periodic_flush=False
|
||||
)
|
||||
response = await datadog_metrics_logger.async_health_check()
|
||||
response = await datadog_metrics_logger.async_health_check() # type: ignore[attr-defined]
|
||||
return {
|
||||
"status": response["status"],
|
||||
"message": (
|
||||
|
|
|
|||
|
|
@ -286,7 +286,8 @@ async def test_output_parsing():
|
|||
}
|
||||
]
|
||||
|
||||
pii_masking.pii_tokens = {"<PERSON>": "Jane Doe", "<PHONE_NUMBER>": "034453334"}
|
||||
pii_tokens = {"<PERSON>": "Jane Doe", "<PHONE_NUMBER>": "034453334"}
|
||||
pii_masking.pii_tokens = pii_tokens
|
||||
|
||||
response = mock_completion(
|
||||
model="gpt-3.5-turbo",
|
||||
|
|
@ -296,7 +297,8 @@ async def test_output_parsing():
|
|||
new_response = await pii_masking.async_post_call_success_hook(
|
||||
user_api_key_dict=UserAPIKeyAuth(),
|
||||
data={
|
||||
"messages": [{"role": "system", "content": "You are an helpfull assistant"}]
|
||||
"messages": [{"role": "system", "content": "You are an helpfull assistant"}],
|
||||
"pii_tokens": pii_tokens,
|
||||
},
|
||||
response=response,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1559,6 +1559,7 @@ async def test_resolve_jwks_url_caches_resolved_jwks_uri():
|
|||
jwks_url = "https://login.microsoftonline.com/tenant/discovery/keys"
|
||||
|
||||
mock_response = MagicMock()
|
||||
mock_response.status_code = 200
|
||||
mock_response.json.return_value = {"jwks_uri": jwks_url}
|
||||
|
||||
with patch.object(handler.http_handler, "get", new_callable=AsyncMock, return_value=mock_response) as mock_get:
|
||||
|
|
@ -1587,6 +1588,7 @@ async def test_resolve_jwks_url_raises_if_no_jwks_uri_in_discovery_doc():
|
|||
|
||||
discovery_url = "https://example.com/.well-known/openid-configuration"
|
||||
mock_response = MagicMock()
|
||||
mock_response.status_code = 200
|
||||
mock_response.json.return_value = {"issuer": "https://example.com"} # no jwks_uri
|
||||
|
||||
with patch.object(handler.http_handler, "get", new_callable=AsyncMock, return_value=mock_response):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue