test(proxy): type the parameters of the per-chunk overhead tests
Some checks failed
Cost map pins recheck / rerun-cost-map-guard (push) Has been cancelled
LiteLLM Rust DB / db-queries (push) Has been cancelled
LiteLLM Rust / rust-lint (push) Has been cancelled
LiteLLM Rust / rust-test (push) Has been cancelled
LiteLLM Rust / rust-wheel (push) Has been cancelled
Terraform Modules / fmt, validate, test (aws) (push) Has been cancelled
Terraform Modules / fmt, validate, test (gcp) (push) Has been cancelled

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
kerry 2026-11-06 02:53:01 +00:00
parent c611839835
commit 2cdcd9dafa
2 changed files with 9 additions and 9 deletions

View file

@ -5202,9 +5202,7 @@ class TestHandleLLMApiExceptionProviderOverload:
assert proxy_exc.type == "internal_server_error"
assert proxy_exc.to_dict()["code"] == "500"
async def test_openai_route_answers_wrapped_provider_overload_as_503(
self, monkeypatch: pytest.MonkeyPatch
) -> None:
async def test_openai_route_answers_wrapped_provider_overload_as_503(self, monkeypatch: pytest.MonkeyPatch) -> None:
original: Final = InternalServerError(
message="Overloaded",
llm_provider="anthropic",
@ -5436,12 +5434,14 @@ class TestAsyncStreamingDataGeneratorFastPath:
ProxyLogging._callback_capabilities_cache.clear()
@pytest.mark.asyncio
async def test_slow_path_records_per_chunk_work_on_the_logging_object(self, monkeypatch):
async def test_slow_path_records_per_chunk_work_on_the_logging_object(self, monkeypatch: pytest.MonkeyPatch):
"""The overhead header is stamped before any chunk is read, so the time the proxy spends in
the per-chunk hook has to be recorded on the logging object for the success callback to add."""
class _StreamingCb(CustomLogger):
async def async_post_call_streaming_hook(self, user_api_key_dict, response):
async def async_post_call_streaming_hook(
self, user_api_key_dict: UserAPIKeyAuth, response: object
) -> object:
return response
monkeypatch.setattr(litellm, "callbacks", [_StreamingCb()])
@ -5449,7 +5449,7 @@ class TestAsyncStreamingDataGeneratorFastPath:
proxy_logging_obj = ProxyLogging(user_api_key_cache=MagicMock())
async def slow_hook(**kw):
async def slow_hook(**kw: object) -> object:
await asyncio.sleep(0.02)
return kw["response"]

View file

@ -11,7 +11,7 @@ import subprocess
import sys
import time
import types
from collections.abc import Callable, Iterator, Mapping, Sequence
from collections.abc import AsyncIterator, Callable, Iterator, Mapping, Sequence
from datetime import datetime, timedelta, timezone
from pathlib import Path
from types import MappingProxyType
@ -7582,11 +7582,11 @@ async def test_async_data_generator_records_per_chunk_work_on_the_logging_object
mock_proxy_logging_obj = MagicMock(spec=ProxyLogging)
async def mock_streaming_iterator(*args, **kwargs):
async def mock_streaming_iterator(*args: object, **kwargs: object) -> AsyncIterator[object]:
for chunk in mock_chunks:
yield chunk
async def slow_hook(**kwargs):
async def slow_hook(**kwargs: object) -> object:
await asyncio.sleep(0.02)
return kwargs.get("response")