From 6265437592e9d2401cae1149b9747e2eb2082572 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 2 Sep 2026 22:35:02 +0000 Subject: [PATCH] chore(techdebt): avoid new mutable literal in gigachat tool conversion Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- basedpyright-code-budget.json | 6 +++--- litellm/llms/gigachat/chat/transformation.py | 8 +++++++- type-discipline-budget.json | 6 +++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/basedpyright-code-budget.json b/basedpyright-code-budget.json index 449ed5bfa1e..e03ed8abdca 100644 --- a/basedpyright-code-budget.json +++ b/basedpyright-code-budget.json @@ -57,7 +57,7 @@ "limit": 5601 }, "reportMissingTypeArgument": { - "limit": 15296 + "limit": 15292 }, "reportMissingTypeStubs": { "limit": 40 @@ -105,13 +105,13 @@ "limit": 109 }, "reportUnknownMemberType": { - "limit": 38341 + "limit": 38335 }, "reportUnknownParameterType": { "limit": 19625 }, "reportUnknownVariableType": { - "limit": 29873 + "limit": 29865 }, "reportUnnecessaryCast": { "limit": 111 diff --git a/litellm/llms/gigachat/chat/transformation.py b/litellm/llms/gigachat/chat/transformation.py index 991a93ccb21..89920ebd27b 100644 --- a/litellm/llms/gigachat/chat/transformation.py +++ b/litellm/llms/gigachat/chat/transformation.py @@ -10,6 +10,7 @@ import json import time import uuid from collections.abc import AsyncIterator, Iterator, Mapping, Sequence +from types import MappingProxyType from typing import TYPE_CHECKING, Any, Final import httpx @@ -34,6 +35,9 @@ else: LiteLLMLoggingObj = Any +_EMPTY_FUNCTION: Final[Mapping[str, object]] = MappingProxyType({}) + + def is_valid_json(value: str) -> bool: """Checks whether the value passed is a valid serialized JSON string""" try: @@ -213,7 +217,9 @@ class GigaChatConfig(BaseConfig): "parameters": function.get("parameters", {}), } for function in ( - tool.get("function", {}) for tool in tools if isinstance(tool, dict) and tool.get("type") == "function" + tool.get("function", _EMPTY_FUNCTION) + for tool in tools + if isinstance(tool, dict) and tool.get("type") == "function" ) ] diff --git a/type-discipline-budget.json b/type-discipline-budget.json index 5a4cae71d41..45d00a71d39 100644 --- a/type-discipline-budget.json +++ b/type-discipline-budget.json @@ -6,7 +6,7 @@ "limit": 26774 }, "LIT003": { - "limit": 264 + "limit": 262 }, "LIT004": { "limit": 40 @@ -27,10 +27,10 @@ "limit": 0 }, "LIT010": { - "limit": 16492 + "limit": 16488 }, "LIT011": { - "limit": 5527 + "limit": 5523 }, "LIT012": { "limit": 4495