Skip to content

Commit eb6c902

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

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
from __future__ import annotations
22

33
import logging
4-
from typing import Union
4+
from typing import TypeAlias, Union
55

66
from requests_toolbelt.multipart.decoder import MultipartDecoder # type: ignore
77

88
from unstructured_client._hooks.custom.common import UNSTRUCTURED_CLIENT_LOGGER_NAME
99
from unstructured_client.models import shared
1010

1111
logger = 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

1414
PARTITION_FORM_FILES_KEY = "files"
1515
PARTITION_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

Comments
 (0)