fix: clear type-discipline gate breaches (LIT001 +3, LIT009 +3)

LIT009: the PR's three # type: ignore on chunk.choices / response.choices
were dead (enableTypeIgnoreComments is false), and LIT009 is frozen at
limit 0. Removed them and widened the three receiving signatures to
Sequence[... | Choices] so the list/Choices/StreamingChoices call sites
assign cleanly by covariance.

LIT001: the +3 came from the new code's mutable-collection annotations
(classifier choices list, new accumulator helper choices list, and the
_is_thinking_disabled dict param) — switched to Sequence / Mapping
read-only views.
This commit is contained in:
Daniel Cherubini 2026-09-14 19:00:20 +02:00
parent 9ed3724789
commit 54c7405083
3 changed files with 8 additions and 8 deletions

View file

@ -319,7 +319,7 @@ ANTHROPIC_ADAPTER: Final = AnthropicAdapter()
class LiteLLMMessagesToCompletionTransformationHandler:
@staticmethod
def _is_thinking_disabled(thinking: dict | None) -> bool:
def _is_thinking_disabled(thinking: Mapping | None) -> bool:
"""Return True when the client's thinking param is absent or explicitly disabled."""
return thinking is None or (isinstance(thinking, dict) and thinking.get("type") == "disabled")

View file

@ -1169,7 +1169,7 @@ class AnthropicStreamWrapper(AdapterCompletionStreamWrapper):
return (
LiteLLMAnthropicMessagesAdapter._classify_streaming_chunk(
choices=chunk.choices, # type: ignore
choices=chunk.choices,
thinking_disabled=thinking_disabled,
)
!= "skip"
@ -1232,7 +1232,7 @@ class AnthropicStreamWrapper(AdapterCompletionStreamWrapper):
block_type,
content_block_start,
) = LiteLLMAnthropicMessagesAdapter()._translate_streaming_openai_chunk_to_anthropic_content_block(
choices=chunk.choices, # type: ignore
choices=chunk.choices,
thinking_disabled=self.thinking_disabled,
)

View file

@ -1562,7 +1562,7 @@ class LiteLLMAnthropicMessagesAdapter:
@staticmethod
def _classify_streaming_chunk(
choices: list["OpenAIStreamingChoice | StreamingChoices"],
choices: Sequence["OpenAIStreamingChoice | StreamingChoices"],
thinking_disabled: bool = False,
) -> Literal["thinking", "redacted_thinking", "tool_use", "text", "skip"]:
"""
@ -1667,7 +1667,7 @@ class LiteLLMAnthropicMessagesAdapter:
def _translate_streaming_openai_chunk_to_anthropic_content_block(
self,
choices: list[OpenAIStreamingChoice | StreamingChoices],
choices: Sequence["OpenAIStreamingChoice | StreamingChoices | Choices"],
thinking_disabled: bool = False,
) -> tuple[
Literal["text", "tool_use", "thinking", "redacted_thinking"],
@ -1732,7 +1732,7 @@ class LiteLLMAnthropicMessagesAdapter:
def _translate_streaming_openai_chunk_to_anthropic(
self,
choices: list[OpenAIStreamingChoice | StreamingChoices],
choices: Sequence["OpenAIStreamingChoice | StreamingChoices | Choices"],
thinking_disabled: bool = False,
) -> tuple[
StreamingContentBlockDeltaType,
@ -1757,7 +1757,7 @@ class LiteLLMAnthropicMessagesAdapter:
def _accumulate_streaming_chunk_payloads(
self,
choices: list[OpenAIStreamingChoice | StreamingChoices],
choices: Sequence["OpenAIStreamingChoice | StreamingChoices"],
thinking_disabled: bool = False,
) -> tuple[str, str, str, str | None]:
"""Fold a chunk's choices into (text, reasoning_content, reasoning_signature, partial_json).
@ -1838,7 +1838,7 @@ class LiteLLMAnthropicMessagesAdapter:
type_of_content,
content_block_delta,
) = self._translate_streaming_openai_chunk_to_anthropic(
choices=response.choices, # type: ignore
choices=response.choices,
thinking_disabled=thinking_disabled,
)
return ContentBlockDelta(