style: satisfy LIT010 on the lines this PR touches

The base gained LIT010 (assignment without a Final declaration) while this PR was
open, so code that passed the gate at the old base now trips it.

Three are genuinely never rebound and take Final: `per_message`, `chunks`, and the
awaited fetch result, which is now bound separately so the unpack below has room
for its reason.

Two are real rebinding and say so. `total` is the running byte count the cap is
measured against. `mime_type` is overwritten further down when the caller passes
`format`, so it cannot be Final; the reason sits on the unpack line itself, since
a reason on the preceding line does not count.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
samtsai15 2026-08-27 16:11:44 +08:00
parent 5008f1f97e
commit e84522118c
3 changed files with 5 additions and 4 deletions

View file

@ -3571,7 +3571,8 @@ class BedrockImageProcessor:
# against the previous signature, so an additive parameter would
# break them; omitting it keeps the call byte-for-byte as it was.
capped: Final = {} if max_bytes is None else {"max_bytes": max_bytes} # mutable-ok: kwargs for one call
img_bytes, mime_type = await BedrockImageProcessor.get_image_details_async(image_url, **capped)
fetched: Final = await BedrockImageProcessor.get_image_details_async(image_url, **capped)
img_bytes, mime_type = fetched # rebind-ok: mime_type is overridden below by `format`
image_format = mime_type.split("/")[1]
else:
raise ValueError("Unsupported image type. Expected either image url or base64 encoded string")

View file

@ -455,8 +455,8 @@ async def _async_get_capped(
Returns a fully-read response so callers keep using ``.content`` as before.
"""
async with _underlying_httpx_client(client).stream("GET", url, **request_kwargs) as response:
chunks: list[bytes] = [] # mutable-ok: accumulator for the capped body
total = 0
chunks: Final[list[bytes]] = [] # mutable-ok: accumulator for the capped body
total = 0 # rebind-ok: running byte count for the cap
async for chunk in response.aiter_bytes():
total += len(chunk)
if total > max_bytes:

View file

@ -417,7 +417,7 @@ class BedrockGuardrail(CustomGuardrail, BaseAWSLLM):
return bedrock_request
budget: Final = _ImageFetchBudget()
per_message = await asyncio.gather(
per_message: Final = await asyncio.gather(
*(self._build_input_content_items(message=message, budget=budget) for message in messages)
)
# mutable-ok: BedrockRequest["content"] is a list in the AWS wire format