Skip to content
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
10 changes: 10 additions & 0 deletions docs/misc/error.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-------------
Mindee Errors
-------------

.. automodule:: mindee.error
:imported-members:
:inherited-members:
:members:
:undoc-members:

5 changes: 5 additions & 0 deletions docs/parsing/custom.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ List Field Value
----------------
.. autoclass:: mindee.parsing.custom.list.ListFieldValueV1
:members:

String Dict
-----------
.. autoclass:: mindee.parsing.common.string_dict.StringDict
:members:
6 changes: 6 additions & 0 deletions docs/parsing/standard.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Text Field
:members:
:inherited-members:

Classification Field
--------------------
.. autoclass:: mindee.parsing.standard.classification.ClassificationField
:members:
:inherited-members:

Company Registration Field
--------------------------
.. autoclass:: mindee.parsing.standard.company_registration.CompanyRegistrationField
Expand Down
16 changes: 16 additions & 0 deletions docs/product/receipt_v4.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Receipt V4
----------

**Sample Code:**

.. literalinclude:: /extras/code_samples/expense_receipts_v4.txt
:language: Python

.. autoclass:: mindee.product.receipt.receipt_v4.ReceiptV4
:members:
:inherited-members:

.. autoclass:: mindee.product.receipt.receipt_v4_document.ReceiptV4Document
:members:
:inherited-members:

3 changes: 3 additions & 0 deletions mindee/error/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from mindee.error.geometry_error import GeometryError
from mindee.error.mimetype_error import MimeTypeError
from mindee.error.mindee_error import MindeeClientError, MindeeError
from mindee.error.mindee_http_error import (
MindeeHTTPClientError,
MindeeHTTPError,
MindeeHTTPServerError,
handle_error,
)
File renamed without changes.
2 changes: 2 additions & 0 deletions mindee/error/mimetype_error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class MimeTypeError(AssertionError):
"""The MIME Type is not valid."""
8 changes: 6 additions & 2 deletions mindee/error/mindee_error.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
class MindeeError(RuntimeError):
"""A generic exception relating to various client errors."""
"""A generic exception relating to various HTTP errors."""


class MindeeClientError(MindeeError):
"""An exception relating to document parsing."""
"""
An exception relating to document parsing errors.

Not to be confused with `MindeeHTTPClientError`.
"""


class MindeeApiError(MindeeError):
Expand Down
1 change: 0 additions & 1 deletion mindee/geometry/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from mindee.geometry.bbox import BBox, get_bbox
from mindee.geometry.error import GeometryError
from mindee.geometry.minmax import MinMax, get_min_max_x, get_min_max_y
from mindee.geometry.point import Point, Points
from mindee.geometry.polygon import (
Expand Down
2 changes: 1 addition & 1 deletion mindee/geometry/quadrilateral.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import NamedTuple, Sequence

from mindee.error.geometry_error import GeometryError
from mindee.geometry.bbox import get_bbox
from mindee.geometry.error import GeometryError
from mindee.geometry.point import Point, Points
from mindee.geometry.polygon_utils import get_centroid

Expand Down
10 changes: 10 additions & 0 deletions mindee/input/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from mindee.input.page_options import PageOptions
from mindee.input.sources import (
Base64Input,
BytesInput,
FileInput,
InputType,
LocalInputSource,
PathInput,
UrlInputSource,
)
5 changes: 1 addition & 4 deletions mindee/input/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import pikepdf

from mindee.error.mimetype_error import MimeTypeError
from mindee.error.mindee_error import MindeeSourceError
from mindee.input.page_options import KEEP_ONLY, REMOVE
from mindee.logger import logger
Expand Down Expand Up @@ -36,10 +37,6 @@ class InputType(Enum):
URL = "url"


class MimeTypeError(AssertionError):
"""The MIME Type is not valid."""


class LocalInputSource:
"""Base class for all input sources coming from the local machine."""

Expand Down
1 change: 1 addition & 0 deletions mindee/mindee_http/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from mindee.mindee_http.base_endpoint import BaseEndpoint
from mindee.mindee_http.endpoint import CustomEndpoint, Endpoint
from mindee.mindee_http.mindee_api import MindeeApi
4 changes: 2 additions & 2 deletions mindee/mindee_http/base_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@


class BaseEndpoint(ABC):
"""Base endpoint for the Mindee API."""
"""Base endpoint class for the Mindee API."""

def __init__(self, settings: MindeeApi) -> None:
"""
Base API endpoint class for all endpoints.

:param settings: Settings relating to all endpoints
:param settings: Settings relating to all endpoints.
"""
self.settings = settings
6 changes: 4 additions & 2 deletions mindee/parsing/common/inference.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Generic, List, Optional, TypeVar
from typing import Dict, Generic, List, Optional, Type, TypeVar

from mindee.error.mindee_error import MindeeError
from mindee.parsing.common.page import TypePage
Expand Down Expand Up @@ -55,11 +55,13 @@ def __str__(self) -> str:
)

@staticmethod
def get_endpoint_info(klass) -> Dict[str, str]:
def get_endpoint_info(klass: Type["Inference"]) -> Dict[str, str]:
"""
Retrives the endpoint information for an Inference.

Should never retrieve info for CustomV1, as a custom endpoint should be created to use CustomV1.

:param klass: product subclass to access endpoint information.
"""
if klass.endpoint_name and klass.endpoint_version:
return {"name": klass.endpoint_name, "version": klass.endpoint_version}
Expand Down
1 change: 1 addition & 0 deletions mindee/parsing/common/string_dict.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import Any, Dict

StringDict = Dict[str, Any]
"""Basic JSON-compliant python dictionary."""
2 changes: 1 addition & 1 deletion mindee/parsing/standard/position.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from mindee.geometry.error import GeometryError
from mindee.error.geometry_error import GeometryError
from mindee.geometry.polygon import Polygon, polygon_from_prediction
from mindee.geometry.quadrilateral import Quadrilateral, quadrilateral_from_prediction
from mindee.parsing.common.string_dict import StringDict
Expand Down
2 changes: 1 addition & 1 deletion tests/test_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import pikepdf
import pytest

from mindee.error.mimetype_error import MimeTypeError
from mindee.error.mindee_error import MindeeError, MindeeSourceError
from mindee.input.page_options import KEEP_ONLY, REMOVE
from mindee.input.sources import (
Base64Input,
BytesInput,
FileInput,
MimeTypeError,
PathInput,
UrlInputSource,
)
Expand Down