From 669761f7c88a827d119c5e5db77063c0b8009970 Mon Sep 17 00:00:00 2001 From: "feng.tsai" Date: Wed, 2 Sep 2026 14:27:32 +0800 Subject: [PATCH] fix(guardrails): satisfy ruff format and the test-tree lint Two leftovers from narrowing this PR, both caught by CI's lint job: - `_bin_pack_bedrock_content` kept its `lengths` tuple wrapped over three lines after the image dimension came out, but the expression fits on one again, so `ruff format --check` wanted it back. It now matches the base byte for byte and the function drops out of the diff entirely. - the test module's top-level `from datetime import datetime, timezone` had no remaining user: the only `datetime` reference resolves through the local `import datetime` inside `test_load_credentials_assumes_role_with_external_id`, so the top-level form was shadowed and tripped F811. --- .../proxy/guardrails/guardrail_hooks/bedrock_guardrails.py | 4 +--- .../guardrails/guardrail_hooks/test_bedrock_guardrails.py | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py b/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py index ab987ec4c48..13c7b611e8a 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py +++ b/litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py @@ -1649,9 +1649,7 @@ class BedrockGuardrail(CustomGuardrail, BaseAWSLLM): if not content: return (tuple(content),) - lengths: Final = tuple( - len((item.get("text") or BedrockTextContent()).get("text") or "") for item in content - ) + lengths: Final = tuple(len((item.get("text") or BedrockTextContent()).get("text") or "") for item in content) def assign(carried: tuple[int, int], length: int) -> tuple[int, int]: batch_index, used = carried diff --git a/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_bedrock_guardrails.py b/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_bedrock_guardrails.py index 045b69dc942..42e66d823b2 100644 --- a/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_bedrock_guardrails.py +++ b/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_bedrock_guardrails.py @@ -6,7 +6,6 @@ import asyncio import base64 import json import sys -from datetime import datetime, timezone from unittest.mock import AsyncMock, MagicMock, patch import httpx