11from __future__ import annotations
22
33import logging
4- from typing import Union
4+ from typing import TypeAlias , Union
55
66from requests_toolbelt .multipart .decoder import MultipartDecoder # type: ignore
77
88from unstructured_client ._hooks .custom .common import UNSTRUCTURED_CLIENT_LOGGER_NAME
99from unstructured_client .models import shared
1010
1111logger = logging .getLogger (UNSTRUCTURED_CLIENT_LOGGER_NAME )
12- FormData = dict [str , Union [str , shared .Files , list [str ]]]
12+ FormData : TypeAlias = dict [str , Union [str , shared .Files , list [str ]]]
1313
1414PARTITION_FORM_FILES_KEY = "files"
1515PARTITION_FORM_SPLIT_PDF_PAGE_KEY = "split_pdf_page"
@@ -32,6 +32,7 @@ def get_page_range(form_data: FormData, key: str, max_pages: int) -> tuple[int,
3232 Returns:
3333 The range of pages to send in the request in the form (start, end)
3434 """
35+ _page_range = None
3536 try :
3637 _page_range = form_data .get (key )
3738
@@ -202,7 +203,7 @@ def parse_form_data(decoded_data: MultipartDecoder) -> FormData:
202203 form_data : FormData = {}
203204
204205 for part in decoded_data .parts :
205- content_disposition = part .headers .get (b "Content-Disposition" )
206+ content_disposition = part .headers .get ("Content-Disposition" )
206207 if content_disposition is None :
207208 raise RuntimeError ("Content-Disposition header not found. Can't split pdf file." )
208209 part_params = decode_content_disposition (content_disposition )
0 commit comments