From cb8d5f42d8554642d615781658b45d9e872b63fa Mon Sep 17 00:00:00 2001 From: amazingniuma-art Date: Sun, 27 Sep 2026 17:57:09 +0800 Subject: [PATCH] fix(anthropic): satisfy basedpyright loop binding rules --- litellm/litellm_core_utils/prompt_templates/factory.py | 4 ++-- litellm/llms/anthropic/chat/transformation.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/litellm/litellm_core_utils/prompt_templates/factory.py b/litellm/litellm_core_utils/prompt_templates/factory.py index cf5580b6692..725da3cd7a7 100644 --- a/litellm/litellm_core_utils/prompt_templates/factory.py +++ b/litellm/litellm_core_utils/prompt_templates/factory.py @@ -2407,7 +2407,7 @@ def anthropic_messages_pt( ) = messages[msg_i] if user_message_types_block["role"] == "user": if isinstance(user_message_types_block["content"], list): - user_content_start: Final = len(user_content) + user_content_start: int = len(user_content) for m in user_message_types_block["content"]: if m.get("type", "") == "image_url": m = cast(ChatCompletionImageObject, m) @@ -2691,7 +2691,7 @@ def anthropic_messages_pt( ): # IMPORTANT: ADD THIS FIRST, ELSE ANTHROPIC WILL RAISE AN ERROR assistant_content.extend(thinking_blocks) if _content_is_list and _content_list is not None: - assistant_content_start: Final = len(assistant_content) + assistant_content_start: int = len(assistant_content) for m in _content_list: if not isinstance(m, dict): continue diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.py index 24902c87ac2..8ec20eff068 100644 --- a/litellm/llms/anthropic/chat/transformation.py +++ b/litellm/llms/anthropic/chat/transformation.py @@ -1719,7 +1719,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): anthropic_system_message_content["cache_control"] = system_message_block["cache_control"] anthropic_system_message_list.append(anthropic_system_message_content) elif isinstance(message["content"], list): - content_start: Final = len(anthropic_system_message_list) + content_start: int = len(anthropic_system_message_list) for _content in message["content"]: # Skip empty text blocks - Anthropic API raises errors for empty text text_value = _content.get("text")