Skip to content

Commit a0d6cbf

Browse files
fix broken syntax for 3.8
1 parent 498a5af commit a0d6cbf

3 files changed

Lines changed: 42 additions & 5 deletions

File tree

mindee/error/mindee_http_error_v2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import json
2-
from typing import Optional
2+
from typing import List, Optional
33

44
from mindee.parsing.common.string_dict import StringDict
55
from mindee.parsing.v2 import ErrorItem, ErrorResponse
@@ -18,7 +18,7 @@ def __init__(self, response: ErrorResponse) -> None:
1818
self.title = response.title
1919
self.code = response.code
2020
self.detail = response.detail
21-
self.errors: list[ErrorItem] = response.errors
21+
self.errors: List[ErrorItem] = response.errors
2222
super().__init__(
2323
f"HTTP {self.status} - {self.title} :: {self.code} - {self.detail}"
2424
)

mindee/mindee_http/mindee_api_v2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
from typing import Dict, Optional, Union
2+
from typing import Dict, List, Optional, Union
33

44
import requests
55

@@ -87,7 +87,7 @@ def req_post_inference_enqueue(
8787
"""
8888
if not slug:
8989
slug = "inferences"
90-
data: Dict[str, Union[str, list]] = {"model_id": params.model_id}
90+
data: Dict[str, Union[str, List[str]]] = {"model_id": params.model_id}
9191
url = f"{self.url_root}/{slug}/enqueue"
9292
if isinstance(params, InferenceParameters):
9393
self._set_inference_params(data, params)
@@ -118,7 +118,7 @@ def req_post_inference_enqueue(
118118
return response
119119

120120
def _set_inference_params(
121-
self, data: dict[str, Union[str, list]], params: InferenceParameters
121+
self, data: Dict[str, Union[str, List[str]]], params: InferenceParameters
122122
) -> None:
123123
"""
124124
Sets the inference-specific parameters.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import os
2+
3+
import pytest
4+
5+
from mindee import ClientV2, PathInput
6+
from mindee.input import UtilityParameters
7+
from mindee.v2 import SplitResponse
8+
from tests.utils import FILE_TYPES_DIR
9+
10+
11+
@pytest.fixture(scope="session")
12+
def split_model_id() -> str:
13+
"""Identifier of the Financial Document model, supplied through an env var."""
14+
return os.getenv("MINDEE_V2_SPLIT_UTILITY_MODEL_ID")
15+
16+
17+
@pytest.fixture(scope="session")
18+
def v2_client() -> ClientV2:
19+
"""
20+
Real V2 client configured with the user-supplied API key
21+
(or skipped when the key is absent).
22+
"""
23+
api_key = os.getenv("MINDEE_V2_API_KEY")
24+
return ClientV2(api_key)
25+
26+
27+
@pytest.mark.integration
28+
@pytest.mark.v2
29+
def test_split_blank(v2_client: ClientV2, split_model_id: str):
30+
input_source = PathInput(FILE_TYPES_DIR / "pdf" / "blank_1.pdf")
31+
response = v2_client.enqueue_and_get_utility(
32+
SplitResponse, input_source, UtilityParameters(split_model_id)
33+
)
34+
assert response.inference is not None
35+
assert response.inference.file.name == "blank_1.pdf"
36+
assert response.inference.result.get("split")
37+
assert len(response.inference.result.get("split")) == 1

0 commit comments

Comments
 (0)