From c9c03ebe9ac408ef698593628a006bfd4bf32ed4 Mon Sep 17 00:00:00 2001 From: CreateRandom Date: Thu, 16 Apr 2026 09:54:49 +0200 Subject: [PATCH] style: apply black formatting --- litellm/proxy/common_request_processing.py | 24 +++++++++++-------- .../proxy/test_client_disconnection.py | 13 ++++++---- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/litellm/proxy/common_request_processing.py b/litellm/proxy/common_request_processing.py index 2ac792b04f7..33a69000223 100644 --- a/litellm/proxy/common_request_processing.py +++ b/litellm/proxy/common_request_processing.py @@ -900,9 +900,11 @@ class ProxyBaseLLMRequestProcessing: "Request received by LiteLLM: payload too large to log (%d bytes, limit %d). Keys: %s", len(_payload_str), MAX_PAYLOAD_SIZE_FOR_DEBUG_LOG, - list(self.data.keys()) - if isinstance(self.data, dict) - else type(self.data).__name__, + ( + list(self.data.keys()) + if isinstance(self.data, dict) + else type(self.data).__name__ + ), ) else: verbose_proxy_logger.debug( @@ -1181,9 +1183,9 @@ class ProxyBaseLLMRequestProcessing: # aliasing/routing, but the OpenAI-compatible response `model` field should reflect # what the client sent. if requested_model_from_client: - self.data[ - "_litellm_client_requested_model" - ] = requested_model_from_client + self.data["_litellm_client_requested_model"] = ( + requested_model_from_client + ) # Streaming: attach a closure that fires after all guardrail # end-of-stream blocks complete. CSW.__anext__ stores the @@ -1788,7 +1790,9 @@ class ProxyBaseLLMRequestProcessing: verbose_proxy_logger.debug("inside generator") try: str_so_far = "" - async for chunk in proxy_logging_obj.async_post_call_streaming_iterator_hook( + async for ( + chunk + ) in proxy_logging_obj.async_post_call_streaming_iterator_hook( user_api_key_dict=user_api_key_dict, response=response, request_data=request_data, @@ -2016,9 +2020,9 @@ class ProxyBaseLLMRequestProcessing: # Add cache-related fields to **params (handled by Usage.__init__) if cache_creation_input_tokens is not None: - usage_kwargs[ - "cache_creation_input_tokens" - ] = cache_creation_input_tokens + usage_kwargs["cache_creation_input_tokens"] = ( + cache_creation_input_tokens + ) if cache_read_input_tokens is not None: usage_kwargs["cache_read_input_tokens"] = cache_read_input_tokens diff --git a/tests/test_litellm/proxy/test_client_disconnection.py b/tests/test_litellm/proxy/test_client_disconnection.py index 380ac7f9119..bd0b3d5042e 100644 --- a/tests/test_litellm/proxy/test_client_disconnection.py +++ b/tests/test_litellm/proxy/test_client_disconnection.py @@ -1,6 +1,7 @@ """ Test client disconnection detection functionality. """ + import asyncio import pytest from unittest.mock import AsyncMock, MagicMock, patch @@ -13,15 +14,19 @@ async def test_check_request_disconnection_with_disconnect(): """Test that _check_request_disconnection cancels task and sets event when client disconnects.""" mock_request = AsyncMock() mock_request.receive.side_effect = [ - {"type": "http.request"}, # First call - {"type": "http.disconnect"} # Second call - disconnect + {"type": "http.request"}, # First call + {"type": "http.disconnect"}, # Second call - disconnect ] mock_llm_task = MagicMock() # sync mock so .cancel() doesn't return a coroutine disconnect_event = asyncio.Event() - with patch("litellm.proxy.common_request_processing.asyncio.sleep", new_callable=AsyncMock): - await _check_request_disconnection(mock_request, mock_llm_task, disconnect_event) + with patch( + "litellm.proxy.common_request_processing.asyncio.sleep", new_callable=AsyncMock + ): + await _check_request_disconnection( + mock_request, mock_llm_task, disconnect_event + ) mock_llm_task.cancel.assert_called_once() assert disconnect_event.is_set()