mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-06 08:16:43 +00:00
fix(guardrails): avoid empty-dict default to satisfy type-discipline budget
The merge with litellm_internal_staging tightened the LIT002
(mutable-collection construction) ceiling to exactly the current
count, so the `.get("source", {})` default pushed the count 1 over
budget. Reworked to check `source` before indexing instead of
constructing a throwaway empty dict.
This commit is contained in:
parent
2a47f157fe
commit
a46896b436
1 changed files with 2 additions and 2 deletions
|
|
@ -617,8 +617,8 @@ class BedrockGuardrail(CustomGuardrail, BaseAWSLLM):
|
|||
image_format: Final = (
|
||||
_APPLY_GUARDRAIL_IMAGE_FORMATS.get(str(image_block.get("format"))) if image_block else None
|
||||
)
|
||||
# mutable-ok: {} is an empty default for .get, never mutated
|
||||
image_bytes: Final = image_block.get("source", {}).get("bytes") if image_block else None
|
||||
image_source: Final = image_block.get("source") if image_block else None
|
||||
image_bytes: Final = image_source.get("bytes") if image_source else None
|
||||
if image_format is None or not image_bytes:
|
||||
self._handle_unscannable_image(reason="attachment is not a png/jpeg image")
|
||||
return None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue