From f9a1359ca282ffcf2695ee00842fc26a475674cd Mon Sep 17 00:00:00 2001 From: Paolo Antinori Date: Fri, 18 Sep 2026 17:19:38 +0200 Subject: [PATCH] chore: ruff format and import order --- litellm/llms/anthropic/chat/transformation.py | 3 +-- litellm/router.py | 4 +--- .../test_router_finish_reason_failure.py | 12 +++--------- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.py index 3eb7a33594f..ef780b372e1 100644 --- a/litellm/llms/anthropic/chat/transformation.py +++ b/litellm/llms/anthropic/chat/transformation.py @@ -62,7 +62,6 @@ from litellm.types.llms.openai import ( ChatCompletionToolCallChunk, ChatCompletionToolCallFunctionChunk, ChatCompletionToolParam, - OpenAIChatCompletionFinishReason, OpenAIMcpServerTool, OpenAIWebSearchOptions, ) @@ -74,9 +73,9 @@ from litellm.types.responses.main import ( from litellm.types.utils import ( CacheCreationTokenDetails, CompletionTokensDetailsWrapper, - map_finish_reason_and_stash_native, PromptTokensDetailsWrapper, ServerToolUse, + map_finish_reason_and_stash_native, ) from litellm.types.utils import Message as LitellmMessage from litellm.utils import ( diff --git a/litellm/router.py b/litellm/router.py index 09d7ea622ed..10c0102df5c 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -8731,9 +8731,7 @@ class Router: model_info if isinstance(model_info, dict) else None, litellm_params, key="cooldown_time" ) time_to_cooldown: Final = ( - deployment_cooldown - if deployment_cooldown is not None and deployment_cooldown >= 0 - else self.cooldown_time + deployment_cooldown if deployment_cooldown is not None and deployment_cooldown >= 0 else self.cooldown_time ) exception: Final = self._finish_reason_failure_error(model=model, reason=reason) increment_deployment_failures_for_current_minute( diff --git a/tests/router_unit_tests/test_router_finish_reason_failure.py b/tests/router_unit_tests/test_router_finish_reason_failure.py index a11fafa5557..280e7defcea 100644 --- a/tests/router_unit_tests/test_router_finish_reason_failure.py +++ b/tests/router_unit_tests/test_router_finish_reason_failure.py @@ -100,9 +100,7 @@ async def test_chat_completion_mapped_reason_falls_back_and_cools_down(monkeypat ) fake.install(monkeypatch) - response = await router.acompletion( - model="fable-tier", max_tokens=16, messages=[{"role": "user", "content": "hi"}] - ) + response = await router.acompletion(model="fable-tier", max_tokens=16, messages=[{"role": "user", "content": "hi"}]) assert response.model == "claude-opus-5" assert len(fake.calls) == 2 @@ -148,9 +146,7 @@ async def test_mapped_reason_without_fallback_returns_response_and_counts_failur ) fake.install(monkeypatch) - response = await router.acompletion( - model="fable-tier", max_tokens=16, messages=[{"role": "user", "content": "hi"}] - ) + response = await router.acompletion(model="fable-tier", max_tokens=16, messages=[{"role": "user", "content": "hi"}]) assert response.model == "claude-fable-5" assert len(fake.calls) == 1 @@ -166,9 +162,7 @@ async def test_knob_unset_ignores_terminal_stop_reason(monkeypatch: MonkeyPatch) router = Router(model_list=[FABLE_TIER], num_retries=0) fake.install(monkeypatch) - response = await router.acompletion( - model="fable-tier", max_tokens=16, messages=[{"role": "user", "content": "hi"}] - ) + response = await router.acompletion(model="fable-tier", max_tokens=16, messages=[{"role": "user", "content": "hi"}]) assert response.model == "claude-fable-5" assert len(fake.calls) == 1