From 05239e42cad903da123dd77ca77d02db656d2e5b Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Fri, 6 Nov 2026 00:23:01 -0800 Subject: [PATCH] test: narrow the remaining new test helper parameters from bare dict and object --- tests/unit/litellm_core_utils/test_redact_messages.py | 6 ++++-- .../anthropic/chat/test_anthropic_chat_transformation.py | 8 ++++++-- .../test_openai_guardrail_handler.py | 6 +++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/unit/litellm_core_utils/test_redact_messages.py b/tests/unit/litellm_core_utils/test_redact_messages.py index 8dad9984139..8e4bed02d7e 100644 --- a/tests/unit/litellm_core_utils/test_redact_messages.py +++ b/tests/unit/litellm_core_utils/test_redact_messages.py @@ -11,7 +11,7 @@ import importlib import json import os import threading -from collections.abc import AsyncIterator, Mapping +from collections.abc import AsyncIterator, Iterable, Mapping from datetime import datetime from types import MappingProxyType, SimpleNamespace from typing import Final, Optional, Union @@ -248,7 +248,9 @@ def _claude_fetch_call() -> ResponseFunctionWebSearch: ) -def _web_call_summaries(calls: object) -> list[tuple[str, str | None, dict[str, object]]]: +def _web_call_summaries( + calls: Mapping[str, object] | Iterable[object], +) -> list[tuple[str, str | None, dict[str, object]]]: items: Final = calls.values() if isinstance(calls, dict) else calls return [ (call.id, call.status, call.action.model_dump(exclude_none=True)) diff --git a/tests/unit/llms/anthropic/chat/test_anthropic_chat_transformation.py b/tests/unit/llms/anthropic/chat/test_anthropic_chat_transformation.py index ff916080597..ae72af200d4 100644 --- a/tests/unit/llms/anthropic/chat/test_anthropic_chat_transformation.py +++ b/tests/unit/llms/anthropic/chat/test_anthropic_chat_transformation.py @@ -49,7 +49,11 @@ from litellm.llms.bedrock.claude_platform.transformation import BedrockClaudePla from litellm.llms.vertex_ai.vertex_ai_partner_models.anthropic.transformation import ( VertexAIAnthropicConfig, ) -from litellm.types.llms.anthropic import ANTHROPIC_BETA_HEADER_VALUES, ANTHROPIC_TOOL_SEARCH_TOOL_TYPES +from litellm.types.llms.anthropic import ( + ANTHROPIC_BETA_HEADER_VALUES, + ANTHROPIC_TOOL_SEARCH_TOOL_TYPES, + AllAnthropicPassThroughMessageValues, +) from litellm.types.llms.anthropic_messages.anthropic_response import AnthropicMessagesResponse from litellm.types.llms.openai import AllMessageValues, ChatCompletionToolCallFunctionChunk from litellm.types.utils import ChatCompletionToolCallChunk, Choices, Message, ModelResponse, ServerToolUse, Usage @@ -3987,7 +3991,7 @@ def test_server_tool_use_is_not_returned_as_a_client_tool_call( assert choice.message.content == _PARIS_TEXT -def _replayed(*messages: object): +def _replayed(*messages: Mapping[str, object]) -> list[AllAnthropicPassThroughMessageValues]: return anthropic_messages_pt( messages=cast(list[AllMessageValues], list(messages)), # cast-ok: replays history the way clients send it back model="claude-opus-5-5", diff --git a/tests/unit/llms/openai/chat/guardrail_translation/test_openai_guardrail_handler.py b/tests/unit/llms/openai/chat/guardrail_translation/test_openai_guardrail_handler.py index cba406c0252..697f20a6fa3 100644 --- a/tests/unit/llms/openai/chat/guardrail_translation/test_openai_guardrail_handler.py +++ b/tests/unit/llms/openai/chat/guardrail_translation/test_openai_guardrail_handler.py @@ -1703,7 +1703,11 @@ class TestOpenAIChatCompletionsHandlerStreamingOutput: choices=[StreamingChoices(index=0, delta=delta, finish_reason=finish_reason)], ) - def hosted_fetch(tool_input: dict, result: dict, status: Optional[str]) -> dict: + def hosted_fetch( + tool_input: Mapping[str, str], + result: Mapping[str, object], + status: Literal["in_progress", "completed"] | None, + ) -> dict[str, ResponseFunctionWebSearch]: return { "srvtoolu_01Fetch": build_web_search_call( "srvtoolu_01Fetch", tool_input, result, status=status, tool_name="web_fetch"