From 027c694a7f699a516ca6f77baf74848667f8caff Mon Sep 17 00:00:00 2001 From: lkapadiya-DO Date: Tue, 14 Jul 2026 15:13:21 -0700 Subject: [PATCH] style(anthropic-adapter): apply ruff format to pass-through adapters Co-authored-by: Cursor --- .../adapters/streaming_iterator.py | 26 +++++++++---------- .../adapters/transformation.py | 8 ++---- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py b/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py index be09041f4f1..01eb821cc8b 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py @@ -405,16 +405,15 @@ class AnthropicStreamWrapper(AdapterCompletionStreamWrapper): "content_block": initial_block, } ) - processed_first = LiteLLMAnthropicMessagesAdapter().translate_streaming_openai_response_to_anthropic( - response=first_chunk, - current_content_block_index=self.current_content_block_index, + processed_first = ( + LiteLLMAnthropicMessagesAdapter().translate_streaming_openai_response_to_anthropic( + response=first_chunk, + current_content_block_index=self.current_content_block_index, + ) ) # Empty / stop-only first chunk: close the block before the # terminal message_delta so the sequence stays spec-compliant. - if ( - isinstance(processed_first, dict) - and processed_first.get("type") == "message_delta" - ): + if isinstance(processed_first, dict) and processed_first.get("type") == "message_delta": self.chunk_queue.append( { "type": "content_block_stop", @@ -658,14 +657,13 @@ class AnthropicStreamWrapper(AdapterCompletionStreamWrapper): "content_block": initial_block, } ) - processed_first = LiteLLMAnthropicMessagesAdapter().translate_streaming_openai_response_to_anthropic( - response=first_chunk, - current_content_block_index=self.current_content_block_index, + processed_first = ( + LiteLLMAnthropicMessagesAdapter().translate_streaming_openai_response_to_anthropic( + response=first_chunk, + current_content_block_index=self.current_content_block_index, + ) ) - if ( - isinstance(processed_first, dict) - and processed_first.get("type") == "message_delta" - ): + if isinstance(processed_first, dict) and processed_first.get("type") == "message_delta": self.chunk_queue.append( { "type": "content_block_stop", diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py index 1a52e03cd1c..e55932b7662 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py @@ -1410,13 +1410,9 @@ class LiteLLMAnthropicMessagesAdapter: return "thinking", ChatCompletionThinkingBlock( type="thinking", thinking=thinking, signature=signature ) - elif isinstance(choice, StreamingChoices) and hasattr( - choice.delta, "reasoning_content" - ): + elif isinstance(choice, StreamingChoices) and hasattr(choice.delta, "reasoning_content"): if choice.delta.reasoning_content: - return "thinking", ChatCompletionThinkingBlock( - type="thinking", thinking="", signature="" - ) + return "thinking", ChatCompletionThinkingBlock(type="thinking", thinking="", signature="") return "text", TextBlock(type="text", text="")