fix: document intentional type casts in cache PR

This commit is contained in:
Maximilian Rink 2026-10-13 12:47:46 +02:00
parent 8040db0906
commit fed7e34ecc
4 changed files with 7 additions and 7 deletions

View file

@ -211,7 +211,7 @@ class OpenRouterImageEditConfig(BaseImageEditConfig):
if img is None:
continue
mime_type = ImageEditRequestUtils.get_image_content_type(img)
image_bytes = self._read_image_bytes(cast(FileTypes, img))
image_bytes = self._read_image_bytes(cast(FileTypes, img)) # cast-ok: image entries were narrowed by the None check and FileTypes contract
b64_data = base64.b64encode(image_bytes).decode("utf-8")
content_parts.append(
{

View file

@ -417,7 +417,7 @@ class ContextCachingEndpoints(VertexBase):
"Content-Type": "application/json",
}
if isinstance(token, dict):
headers.update(cast(Mapping[str, str], token))
headers.update(cast(Mapping[str, str], token)) # cast-ok: token mapping is returned by the Vertex auth helper
elif token is not None:
headers["Authorization"] = f"Bearer {token}"
if extra_headers is not None:
@ -496,7 +496,7 @@ class ContextCachingEndpoints(VertexBase):
response: Final = client.post(
url=url,
headers=headers,
json=cast(dict[str, object], cached_content_request_body),
json=cast(dict[str, object], cached_content_request_body), # cast-ok: request body is assembled as JSON object data # cast-ok: request body is assembled as JSON object data
)
response.raise_for_status()
except httpx.HTTPStatusError as err:
@ -597,7 +597,7 @@ class ContextCachingEndpoints(VertexBase):
"Content-Type": "application/json",
}
if isinstance(token, dict):
headers.update(cast(Mapping[str, str], token))
headers.update(cast(Mapping[str, str], token)) # cast-ok: token mapping is returned by the Vertex auth helper
elif token is not None:
headers["Authorization"] = f"Bearer {token}"
if extra_headers is not None:
@ -673,7 +673,7 @@ class ContextCachingEndpoints(VertexBase):
response: Final = await client.post(
url=url,
headers=headers,
json=cast(dict[str, object], cached_content_request_body),
json=cast(dict[str, object], cached_content_request_body), # cast-ok: request body is assembled as JSON object data
)
response.raise_for_status()
except httpx.HTTPStatusError as err:

View file

@ -1797,7 +1797,7 @@ def _placeholder_stored_request_body_metadata(
{
"model_group": persisted_model_group,
"error_information": _scrub_raw_model_from_error_information(
cast(StandardLoggingPayloadErrorInformation, error_information),
cast(StandardLoggingPayloadErrorInformation, error_information), # cast-ok: validated mapping is the logging error-information contract
raw_model,
)
if isinstance(error_information, Mapping)

View file

@ -164,7 +164,7 @@ def responses_api_bridge_check(
return model_info, model
try:
model_info = cast(
model_info = cast( # cast-ok: provider metadata helper returns the bridge model-info mapping
dict[str, object],
get_model_info_helper(model=model, custom_llm_provider=custom_llm_provider),
)