fix(anthropic): satisfy basedpyright on document block path

This commit is contained in:
Ruiming Zhao 2026-08-14 17:23:38 -07:00
parent aab5a3cf91
commit 9f1b470eeb

View file

@ -2421,12 +2421,12 @@ def anthropic_messages_pt(
url_str = (
image_url_value.get("url") if isinstance(image_url_value, dict) else image_url_value
)
if isinstance(url_str, str) and _is_anthropic_document_data_uri(url_str):
image_chunk: Final = convert_to_anthropic_image_obj(
if isinstance(url_str, str) and _is_anthropic_document_data_uri(url_str): # pyright: ignore[reportUnnecessaryIsInstance] # malformed payloads can carry a non-str url
image_chunk = convert_to_anthropic_image_obj(
openai_image_url=url_str,
format=None,
)
_document_content_element: Final = AnthropicMessagesDocumentParam(
_document_content_element = AnthropicMessagesDocumentParam(
type="document",
source=AnthropicContentParamSource(
type="base64",
@ -2436,7 +2436,7 @@ def anthropic_messages_pt(
)
add_cache_control_to_content(
anthropic_content_element=_document_content_element,
original_content_element=m,
original_content_element=m, # pyright: ignore[reportArgumentType] # cache_control lives on the block
)
user_content.append(_document_content_element)
continue