From d711cfbc84dac36685c391baf8e83bd3134919b0 Mon Sep 17 00:00:00 2001 From: David-Wu1119 <133224895+David-Wu1119@users.noreply.github.com> Date: Thu, 13 Aug 2026 18:01:06 +0800 Subject: [PATCH] fix(anthropic): annotate the error-chunk builder for the type-discipline gate _make_error_chunk returns a dict because the chunk is appended to _chunk_queue and returned from __anext__, both of which are typed dict[str, Any] by the existing iterator contract in this file. Record that with a mutable-ok reason so the LIT001 budget stays flat. --- .../responses_adapters/streaming_iterator.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/litellm/llms/anthropic/experimental_pass_through/responses_adapters/streaming_iterator.py b/litellm/llms/anthropic/experimental_pass_through/responses_adapters/streaming_iterator.py index 967329d9c42..0ecac7c879f 100644 --- a/litellm/llms/anthropic/experimental_pass_through/responses_adapters/streaming_iterator.py +++ b/litellm/llms/anthropic/experimental_pass_through/responses_adapters/streaming_iterator.py @@ -124,7 +124,9 @@ class AnthropicResponsesStreamWrapper: self._current_block_index += 1 return self._current_block_index - def _make_error_chunk(self, message: str) -> dict[str, Any]: + def _make_error_chunk( + self, message: str + ) -> dict[str, Any]: # mutable-ok: queued into _chunk_queue and returned from __anext__, both typed dict[str, Any] return { "type": "error", "error": {"type": "api_error", "message": message},