From 7987a1fae5aa008e9d16d5f78c11aca0a0df7fda Mon Sep 17 00:00:00 2001 From: Pasqual Troncone Date: Fri, 4 Sep 2026 16:46:14 +0200 Subject: [PATCH] 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. --- litellm/llms/mistral/chat/transformation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litellm/llms/mistral/chat/transformation.py b/litellm/llms/mistral/chat/transformation.py index 4f7ed21bc79..a33f170db71 100644 --- a/litellm/llms/mistral/chat/transformation.py +++ b/litellm/llms/mistral/chat/transformation.py @@ -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