chore(mistral): annotate the tool_choice parameter as a read-only mapping

The type-discipline gate counts a `dict[...]` annotation as a mutable
collection handed to a caller, and the parameter only ever reads its
argument. The runtime check that decides what reaches the mapper stays
`isinstance(value, (str, dict))`, so nothing but the annotation moves.
This commit is contained in:
Pasqual Troncone 2026-09-04 16:46:14 +02:00
parent cbc83e3c01
commit 7987a1fae5

View file

@ -6,7 +6,7 @@ Why separate file? Make it easy to see how transformation works
Docs - https://docs.mistral.ai/api/
"""
from collections.abc import AsyncIterator, Coroutine, Iterator
from collections.abc import AsyncIterator, Coroutine, Iterator, Mapping
from typing import TYPE_CHECKING, Any, Final, Literal, cast, get_type_hints, overload
import httpx
@ -112,7 +112,7 @@ class MistralConfig(OpenAIGPTConfig):
return supported_params
@staticmethod
def _map_tool_choice(tool_choice: str | dict[str, object]) -> str | ChatCompletionToolChoiceObjectParam | None:
def _map_tool_choice(tool_choice: str | Mapping[str, object]) -> str | ChatCompletionToolChoiceObjectParam | None:
match tool_choice:
case "auto" | "none":
return tool_choice