From 612d335f5990b2735b6f84a1eb8537d40c1efc6b Mon Sep 17 00:00:00 2001 From: Yujong Lee Date: Sat, 12 Sep 2026 08:55:19 -0700 Subject: [PATCH] fix(ocr): document native callable casts --- litellm/ocr/input.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/litellm/ocr/input.py b/litellm/ocr/input.py index 2543cbade4c..50af4cc61db 100644 --- a/litellm/ocr/input.py +++ b/litellm/ocr/input.py @@ -30,16 +30,37 @@ class NativeMimeType(Protocol): _FILE_DOCUMENT: Final = NativeBinding( - "_ocr_file_document", validate=lambda value: cast(NativeFileDocument, value) if callable(value) else None + "_ocr_file_document", + validate=lambda value: ( + cast( # cast-ok: native export owns the callable signature + NativeFileDocument, value + ) + if callable(value) + else None + ), ) _UPLOAD_DOCUMENT: Final = NativeBinding( - "_ocr_upload_document", validate=lambda value: cast(NativeUploadDocument, value) if callable(value) else None + "_ocr_upload_document", + validate=lambda value: ( + cast( # cast-ok: native export owns the callable signature + NativeUploadDocument, value + ) + if callable(value) + else None + ), ) _MAX_FILE_BYTES: Final = NativeBinding( "_OCR_MAX_FILE_BYTES", validate=lambda value: value if isinstance(value, int) and value > 0 else None ) _MIME_TYPE: Final = NativeBinding( - "_ocr_mime_type", validate=lambda value: cast(NativeMimeType, value) if callable(value) else None + "_ocr_mime_type", + validate=lambda value: ( + cast( # cast-ok: native export owns the callable signature + NativeMimeType, value + ) + if callable(value) + else None + ), )