test: narrow the remaining new test helper parameters from bare dict and object

This commit is contained in:
mateo-berri 2026-11-06 00:23:01 -08:00
parent 4f97d003a9
commit 05239e42ca
3 changed files with 15 additions and 5 deletions

View file

@ -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))

View file

@ -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",

View file

@ -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"