From de23e1855289bb5f2948af31913d6ca5dc16ee22 Mon Sep 17 00:00:00 2001 From: jungraekim-gif Date: Tue, 9 Jun 2026 09:35:25 +0800 Subject: [PATCH] style: apply Black formatting Co-Authored-By: Claude Sonnet 4.6 --- litellm/utils.py | 4 +--- .../test_retry_count_in_exception_messages.py | 17 +++++++---------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/litellm/utils.py b/litellm/utils.py index f62d5ef030b..dabefb45a73 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -2094,9 +2094,7 @@ def client(original_function): # noqa: PLR0915 # Injecting litellm.num_retries here for router calls causes misleading # "LiteLLM Retried: N times" in error messages even when zero retries # occurred (e.g. TimeoutErrorRetries=0 in retry_policy). - _is_router_or_proxy_call = "model_group" in ( - kwargs.get("metadata") or {} - ) + _is_router_or_proxy_call = "model_group" in (kwargs.get("metadata") or {}) if not _is_router_or_proxy_call: setattr( e, "num_retries", num_retries diff --git a/tests/test_litellm/test_retry_count_in_exception_messages.py b/tests/test_litellm/test_retry_count_in_exception_messages.py index 4a51f7ed45c..318097b56d9 100644 --- a/tests/test_litellm/test_retry_count_in_exception_messages.py +++ b/tests/test_litellm/test_retry_count_in_exception_messages.py @@ -20,11 +20,11 @@ from litellm import Router from litellm.exceptions import Timeout, InternalServerError from litellm.types.router import RetryPolicy - # --------------------------------------------------------------------------- # Helpers # --------------------------------------------------------------------------- + def _make_timeout(message="Connection timed out"): return Timeout( message=message, @@ -61,6 +61,7 @@ def _make_router(retry_policy: dict) -> Router: # exceptions.py: is-not-None check # --------------------------------------------------------------------------- + class TestExceptionStrFormat: def test_zero_num_retries_is_displayed(self): """num_retries=0 should appear in __str__, not be silently suppressed.""" @@ -94,6 +95,7 @@ class TestExceptionStrFormat: # router.py: TimeoutErrorRetries=0 stamps 0 on exception # --------------------------------------------------------------------------- + @pytest.mark.asyncio async def test_timeout_zero_retries_stamps_zero_on_exception(): """ @@ -118,9 +120,7 @@ async def test_timeout_zero_retries_stamps_zero_on_exception(): f"Expected num_retries=0, got {raised.num_retries}. " "TimeoutErrorRetries=0 should stamp 0 retries, not litellm.num_retries." ) - assert raised.max_retries == 0, ( - f"Expected max_retries=0, got {raised.max_retries}." - ) + assert raised.max_retries == 0, f"Expected max_retries=0, got {raised.max_retries}." @pytest.mark.asyncio @@ -141,12 +141,8 @@ async def test_internal_server_error_three_retries_stamps_correctly(): ) raised = exc_info.value - assert raised.num_retries == 3, ( - f"Expected num_retries=3, got {raised.num_retries}." - ) - assert raised.max_retries == 3, ( - f"Expected max_retries=3, got {raised.max_retries}." - ) + assert raised.num_retries == 3, f"Expected num_retries=3, got {raised.num_retries}." + assert raised.max_retries == 3, f"Expected max_retries=3, got {raised.max_retries}." assert mock_call.call_count == 4 # 1 initial + 3 retries @@ -154,6 +150,7 @@ async def test_internal_server_error_three_retries_stamps_correctly(): # utils.py: decorator does not inject litellm.num_retries for router calls # --------------------------------------------------------------------------- + @pytest.mark.asyncio async def test_decorator_does_not_inject_global_num_retries_for_router_calls(): """