fix: satisfy lint and coverage gates

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
yassin 2026-09-02 16:00:56 +00:00
parent 32e43221b9
commit 730d13ccd1
2 changed files with 16 additions and 2 deletions

View file

@ -91,8 +91,10 @@ class LiteLLMCompletionStreamingIterator(ResponsesAPIStreamingIterator):
self.custom_llm_provider: str | None = custom_llm_provider
self.litellm_metadata: dict | None = litellm_metadata or {}
_wrapper_hidden_params: Final = getattr(litellm_custom_stream_wrapper, "_hidden_params", None)
self._hidden_params: dict[str, object] = (
dict(_wrapper_hidden_params) if isinstance(_wrapper_hidden_params, dict) else {}
self._hidden_params: dict[str, object] = ( # mutable-ok: downstream response metadata requires a mutable dict
dict(_wrapper_hidden_params) # mutable-ok: downstream response metadata requires a mutable dict
if isinstance(_wrapper_hidden_params, dict)
else {} # mutable-ok: downstream response metadata requires a mutable dict
)
# Store lightweight dict snapshots for stream_chunk_builder to reduce
# repeated Pydantic attribute access in end-of-stream assembly.

View file

@ -533,6 +533,10 @@ def test_extract_partial_responses_usage_real_bridge_iterator_pre_first_chunk():
self.logging_obj = MagicMock()
self._hidden_params = {"model_id": "deployment-123"}
class _FakeStreamWrapperWithoutHiddenParams:
def __init__(self) -> None:
self.logging_obj = MagicMock()
iterator = LiteLLMCompletionStreamingIterator(
model="anthropic/claude-3-5-sonnet-latest",
litellm_custom_stream_wrapper=_FakeStreamWrapper(),
@ -545,4 +549,12 @@ def test_extract_partial_responses_usage_real_bridge_iterator_pre_first_chunk():
assert iterator._hidden_params == {"model_id": "deployment-123"}
assert not iterator.collected_chat_completion_chunks
iterator_without_hidden_params = LiteLLMCompletionStreamingIterator(
model="anthropic/claude-3-5-sonnet-latest",
litellm_custom_stream_wrapper=_FakeStreamWrapperWithoutHiddenParams(),
request_input="hi",
responses_api_request={},
)
assert iterator_without_hidden_params._hidden_params == {}
assert Router._extract_partial_responses_usage(iterator) is None