From 213ed9b438ec4d2e3c4e242bdab4369abc6febc4 Mon Sep 17 00:00:00 2001 From: yucheng Date: Thu, 5 Nov 2026 02:04:06 -0800 Subject: [PATCH] test(logging): give the failure-capture kwargs and the Langfuse export route full types --- .../integrations/langfuse/test_langfuse.py | 2 +- .../litellm_core_utils/test_litellm_logging.py | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/unit/integrations/langfuse/test_langfuse.py b/tests/unit/integrations/langfuse/test_langfuse.py index 738f2f6ecf7..a1a5f7141ed 100644 --- a/tests/unit/integrations/langfuse/test_langfuse.py +++ b/tests/unit/integrations/langfuse/test_langfuse.py @@ -189,7 +189,7 @@ async def test_langfuse_logging_completion(langfuse_export: tuple[respx.Route, s async def test_langfuse_failure_with_redaction_on_logs_the_error_without_the_prompt( langfuse_export: tuple[respx.Route, str], monkeypatch: pytest.MonkeyPatch ) -> None: - route, _ = langfuse_export + route: Final = langfuse_export[0] prompt: Final = "my ssn is 123-45-6789" monkeypatch.setattr(litellm, "turn_off_message_logging", True) monkeypatch.setattr(litellm, "failure_callback", ["langfuse"]) diff --git a/tests/unit/litellm_core_utils/test_litellm_logging.py b/tests/unit/litellm_core_utils/test_litellm_logging.py index 607fbb41cd5..e0c574830d9 100644 --- a/tests/unit/litellm_core_utils/test_litellm_logging.py +++ b/tests/unit/litellm_core_utils/test_litellm_logging.py @@ -12056,16 +12056,24 @@ SCRUB_PROMPT: Final = "my ssn is 123-45-6789" class _FailureCapture(CustomLogger): def __init__(self, **kwargs: bool) -> None: super().__init__(**kwargs) - self.sync_kwargs: dict | None = None - self.async_kwargs: dict | None = None + self.sync_kwargs: dict[str, object] | None = None + self.async_kwargs: dict[str, object] | None = None def log_failure_event( - self, kwargs: dict, response_obj: object, start_time: datetime.datetime, end_time: datetime.datetime + self, + kwargs: dict[str, object], + response_obj: object, + start_time: datetime.datetime, + end_time: datetime.datetime, ) -> None: self.sync_kwargs = kwargs async def async_log_failure_event( - self, kwargs: dict, response_obj: object, start_time: datetime.datetime, end_time: datetime.datetime + self, + kwargs: dict[str, object], + response_obj: object, + start_time: datetime.datetime, + end_time: datetime.datetime, ) -> None: self.async_kwargs = kwargs @@ -12096,7 +12104,7 @@ def _prompt_echo_error() -> litellm.BadRequestError: async def _async_failure_payload( monkeypatch: pytest.MonkeyPatch, *, redact: bool, error: Exception, capture: _FailureCapture | None = None -) -> dict: +) -> dict[str, object]: logger: Final = capture or _FailureCapture() monkeypatch.setattr(litellm, "turn_off_message_logging", redact) monkeypatch.setattr(litellm, "_async_failure_callback", [logger])