Skip to content

Commit 8f34213

Browse files
committed
add more imports of 'annotations' and fix type hint
1 parent cb06c7e commit 8f34213

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

_test_unstructured_client/integration/test_integration_freemium.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import asyncio
24
import json
35
import os

_test_unstructured_client/unit/test_custom_hooks.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import logging
24
import re
35

src/unstructured_client/_hooks/custom/form_utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
import logging
44
from typing import Union
5+
from typing_extensions import TypeAlias
56

67
from requests_toolbelt.multipart.decoder import MultipartDecoder # type: ignore
78

89
from unstructured_client._hooks.custom.common import UNSTRUCTURED_CLIENT_LOGGER_NAME
910
from unstructured_client.models import shared
1011

1112
logger = logging.getLogger(UNSTRUCTURED_CLIENT_LOGGER_NAME)
12-
FormData = dict[str, Union[str, shared.Files, list[str]]]
13+
FormData: TypeAlias = dict[str, Union[str, shared.Files, list[str]]]
1314

1415
PARTITION_FORM_FILES_KEY = "files"
1516
PARTITION_FORM_SPLIT_PDF_PAGE_KEY = "split_pdf_page"
@@ -32,6 +33,7 @@ def get_page_range(form_data: FormData, key: str, max_pages: int) -> tuple[int,
3233
Returns:
3334
The range of pages to send in the request in the form (start, end)
3435
"""
36+
_page_range = None
3537
try:
3638
_page_range = form_data.get(key)
3739

@@ -202,7 +204,7 @@ def parse_form_data(decoded_data: MultipartDecoder) -> FormData:
202204
form_data: FormData = {}
203205

204206
for part in decoded_data.parts:
205-
content_disposition = part.headers.get(b"Content-Disposition")
207+
content_disposition = part.headers.get("Content-Disposition")
206208
if content_disposition is None:
207209
raise RuntimeError("Content-Disposition header not found. Can't split pdf file.")
208210
part_params = decode_content_disposition(content_disposition)

0 commit comments

Comments
 (0)