Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: py 3.8 support #187

Merged
merged 5 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
test_unit:
strategy:
matrix:
python-version: ["3.9","3.10","3.11"]
python-version: ["3.8", "3.9","3.10","3.11"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -47,7 +47,7 @@ jobs:
test_integration:
strategy:
matrix:
python-version: ["3.9","3.10","3.11"]
python-version: ["3.8", "3.9","3.10","3.11"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 2 additions & 0 deletions _test_unstructured_client/integration/test_decorators.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import httpx
import json
import pytest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import asyncio
import json
import os
Expand Down
2 changes: 2 additions & 0 deletions _test_unstructured_client/unit/test_custom_hooks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
import re

Expand Down
2 changes: 2 additions & 0 deletions _test_unstructured_client/unit/test_split_pdf_hook.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import asyncio
import io
import logging
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Tuple
from urllib.parse import ParseResult, urlparse, urlunparse

Expand Down
11 changes: 8 additions & 3 deletions src/unstructured_client/_hooks/custom/form_utils.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
from __future__ import annotations

import logging
from typing import Union
from typing import TYPE_CHECKING
from typing_extensions import TypeAlias

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

from unstructured_client._hooks.custom.common import UNSTRUCTURED_CLIENT_LOGGER_NAME
from unstructured_client.models import shared

if TYPE_CHECKING:
from typing import Union

logger = logging.getLogger(UNSTRUCTURED_CLIENT_LOGGER_NAME)
FormData = dict[str, Union[str, shared.Files, list[str]]]
FormData: TypeAlias = "dict[str, Union[str, shared.Files, list[str]]]"

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

Expand Down Expand Up @@ -202,7 +207,7 @@ def parse_form_data(decoded_data: MultipartDecoder) -> FormData:
form_data: FormData = {}

for part in decoded_data.parts:
content_disposition = part.headers.get(b"Content-Disposition")
content_disposition = part.headers.get(b"Content-Disposition") # type: ignore
if content_disposition is None:
raise RuntimeError("Content-Disposition header not found. Can't split pdf file.")
part_params = decode_content_disposition(content_disposition)
Expand Down
2 changes: 2 additions & 0 deletions src/unstructured_client/_hooks/custom/logger_hook.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
from typing import Optional, Tuple, Union, DefaultDict

Expand Down
2 changes: 2 additions & 0 deletions src/unstructured_client/_hooks/custom/pdf_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import io
import logging
from typing import cast, Generator, Tuple, Optional
Expand Down
2 changes: 2 additions & 0 deletions src/unstructured_client/_hooks/custom/suggest_defining_url.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Optional, Tuple, Union

import httpx
Expand Down