diff --git a/.github/workflows/tag-version.yml b/.github/workflows/tag-version.yml index 8a669f0e..31194379 100644 --- a/.github/workflows/tag-version.yml +++ b/.github/workflows/tag-version.yml @@ -6,41 +6,5 @@ on: - main jobs: - tag-version: - runs-on: ubuntu-latest - if: "contains(github.event.head_commit.message, ':bookmark:')" - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - - name: Tag version - run: | - msg_start=':bookmark: Version ' - version_format='[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}' - version=$(git log -1 --skip=0 --pretty=%s | grep -oP "(?<=${msg_start})${version_format}") - - if [ -z "${version}" ]; then - echo 'Version not found, aborting.' - exit 1 - fi - - echo "Found version: ${version}"; - tag="v${version}"; - - echo "Would tag: ${tag}"; - existing_tag=$(git tag -l "${tag}"); - - if [ "${existing_tag}" ]; then - echo "Tag '${existing_tag}' already exists, aborting."; - exit 1; - fi - - git config user.name "Mindee"; - git config user.email "opensource@mindee.com" - - git tag -a "${tag}" -m"Version ${version}"; - git push origin "${tag}" - - echo "Tagged and pushed: ${tag}" + tag: + uses: mindee/client-lib-actions/.github/workflows/tag-version.yml@main diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6232f59a..70a6fca4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,7 +39,7 @@ repos: ] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.6.1 + rev: v1.13.0 hooks: - id: mypy args: [] diff --git a/docs/product/business_card_v1.rst b/docs/product/business_card_v1.rst index 7fa9c2d9..bab5ac7a 100644 --- a/docs/product/business_card_v1.rst +++ b/docs/product/business_card_v1.rst @@ -3,7 +3,7 @@ Business Card V1 **Sample Code:** -.. literalinclude:: /extras/code_samples/business_card_v1.txt +.. literalinclude:: /extras/code_samples/business_card_v1_async.txt :language: Python .. autoclass:: mindee.product.business_card.business_card_v1.BusinessCardV1 diff --git a/docs/product/delivery_note_v1.rst b/docs/product/delivery_note_v1.rst index 876ce41b..998b0154 100644 --- a/docs/product/delivery_note_v1.rst +++ b/docs/product/delivery_note_v1.rst @@ -3,7 +3,7 @@ Delivery note V1 **Sample Code:** -.. literalinclude:: /extras/code_samples/delivery_notes_v1.txt +.. literalinclude:: /extras/code_samples/delivery_notes_v1_async.txt :language: Python .. autoclass:: mindee.product.delivery_note.delivery_note_v1.DeliveryNoteV1 diff --git a/docs/product/driver_license_v1.rst b/docs/product/driver_license_v1.rst index d3eed17f..e5545c15 100644 --- a/docs/product/driver_license_v1.rst +++ b/docs/product/driver_license_v1.rst @@ -3,7 +3,7 @@ Driver License V1 **Sample Code:** -.. literalinclude:: /extras/code_samples/driver_license_v1.txt +.. literalinclude:: /extras/code_samples/driver_license_v1_async.txt :language: Python .. autoclass:: mindee.product.driver_license.driver_license_v1.DriverLicenseV1 diff --git a/docs/product/financial_document_v1.rst b/docs/product/financial_document_v1.rst index c224f132..0973a270 100644 --- a/docs/product/financial_document_v1.rst +++ b/docs/product/financial_document_v1.rst @@ -3,7 +3,7 @@ Financial Document V1 **Sample Code:** -.. literalinclude:: /extras/code_samples/financial_document_v1.txt +.. literalinclude:: /extras/code_samples/financial_document_v1_async.txt :language: Python .. autoclass:: mindee.product.financial_document.financial_document_v1.FinancialDocumentV1 diff --git a/docs/product/fr/energy_bill_v1.rst b/docs/product/fr/energy_bill_v1.rst index d2c7b3ae..b06d09b9 100644 --- a/docs/product/fr/energy_bill_v1.rst +++ b/docs/product/fr/energy_bill_v1.rst @@ -3,7 +3,7 @@ Energy Bill V1 **Sample Code:** -.. literalinclude:: /extras/code_samples/energy_bill_fra_v1.txt +.. literalinclude:: /extras/code_samples/energy_bill_fra_v1_async.txt :language: Python .. autoclass:: mindee.product.fr.energy_bill.energy_bill_v1.EnergyBillV1 diff --git a/docs/product/fr/health_card_v1.rst b/docs/product/fr/health_card_v1.rst index dceb3d4f..11b6464d 100644 --- a/docs/product/fr/health_card_v1.rst +++ b/docs/product/fr/health_card_v1.rst @@ -3,7 +3,7 @@ Health Card V1 **Sample Code:** -.. literalinclude:: /extras/code_samples/french_healthcard_v1.txt +.. literalinclude:: /extras/code_samples/french_healthcard_v1_async.txt :language: Python .. autoclass:: mindee.product.fr.health_card.health_card_v1.HealthCardV1 diff --git a/docs/product/fr/payslip_v2.rst b/docs/product/fr/payslip_v2.rst index 0ba285bc..e36fd523 100644 --- a/docs/product/fr/payslip_v2.rst +++ b/docs/product/fr/payslip_v2.rst @@ -3,7 +3,7 @@ Payslip V2 **Sample Code:** -.. literalinclude:: /extras/code_samples/payslip_fra_v2.txt +.. literalinclude:: /extras/code_samples/payslip_fra_v2_async.txt :language: Python .. autoclass:: mindee.product.fr.payslip.payslip_v2.PayslipV2 diff --git a/docs/product/fr/payslip_v3.rst b/docs/product/fr/payslip_v3.rst index fa27c4f1..ca26cd47 100644 --- a/docs/product/fr/payslip_v3.rst +++ b/docs/product/fr/payslip_v3.rst @@ -3,7 +3,7 @@ Payslip V3 **Sample Code:** -.. literalinclude:: /extras/code_samples/payslip_fra_v3.txt +.. literalinclude:: /extras/code_samples/payslip_fra_v3_async.txt :language: Python .. autoclass:: mindee.product.fr.payslip.payslip_v3.PayslipV3 diff --git a/docs/product/invoice_v4.rst b/docs/product/invoice_v4.rst index 4b93e088..03698156 100644 --- a/docs/product/invoice_v4.rst +++ b/docs/product/invoice_v4.rst @@ -3,7 +3,7 @@ Invoice V4 **Sample Code:** -.. literalinclude:: /extras/code_samples/invoices_v4.txt +.. literalinclude:: /extras/code_samples/invoices_v4_async.txt :language: Python .. autoclass:: mindee.product.invoice.invoice_v4.InvoiceV4 diff --git a/docs/product/material_certificate_v1.rst b/docs/product/material_certificate_v1.rst index 62dcf590..dfd25e8d 100644 --- a/docs/product/material_certificate_v1.rst +++ b/docs/product/material_certificate_v1.rst @@ -3,7 +3,7 @@ Material Certificate V1 **Sample Code:** -.. literalinclude:: /extras/code_samples/material_certificate_v1.txt +.. literalinclude:: /extras/code_samples/material_certificate_v1_async.txt :language: Python .. autoclass:: mindee.product.material_certificate.material_certificate_v1.MaterialCertificateV1 diff --git a/docs/product/receipt_v5.rst b/docs/product/receipt_v5.rst index f48ebae7..2003f064 100644 --- a/docs/product/receipt_v5.rst +++ b/docs/product/receipt_v5.rst @@ -3,7 +3,7 @@ Receipt V5 **Sample Code:** -.. literalinclude:: /extras/code_samples/expense_receipts_v5.txt +.. literalinclude:: /extras/code_samples/expense_receipts_v5_async.txt :language: Python .. autoclass:: mindee.product.receipt.receipt_v5.ReceiptV5 diff --git a/docs/product/resume_v1.rst b/docs/product/resume_v1.rst index b7d597c4..6a7459e3 100644 --- a/docs/product/resume_v1.rst +++ b/docs/product/resume_v1.rst @@ -3,7 +3,7 @@ Resume V1 **Sample Code:** -.. literalinclude:: /extras/code_samples/resume_v1.txt +.. literalinclude:: /extras/code_samples/resume_v1_async.txt :language: Python .. autoclass:: mindee.product.resume.resume_v1.ResumeV1 diff --git a/docs/product/us/healthcare_card_v1.rst b/docs/product/us/healthcare_card_v1.rst index 9b187ab9..ee6fd476 100644 --- a/docs/product/us/healthcare_card_v1.rst +++ b/docs/product/us/healthcare_card_v1.rst @@ -3,7 +3,7 @@ Healthcare Card V1 **Sample Code:** -.. literalinclude:: /extras/code_samples/us_healthcare_cards_v1.txt +.. literalinclude:: /extras/code_samples/us_healthcare_cards_v1_async.txt :language: Python .. autoclass:: mindee.product.us.healthcare_card.healthcare_card_v1.HealthcareCardV1 diff --git a/mindee/cli.py b/mindee/cli.py index 157b0ee6..de846663 100644 --- a/mindee/cli.py +++ b/mindee/cli.py @@ -313,15 +313,11 @@ def __init__( parser if parser else MindeeArgumentParser(description="Mindee_API") ) self.parsed_args = parsed_args if parsed_args else self._set_args() - self.client = ( - client - if client - else Client( - api_key=( - self.parsed_args.api_key if "api_key" in self.parsed_args else None - ) - ) - ) + if client: + self.client = client + else: + api_key = self.parsed_args.api_key if "api_key" in self.parsed_args else "" + self.client = Client(api_key=api_key) self._set_input() self.document_info = ( document_info if document_info else DOCUMENTS[self.parsed_args.product_name] diff --git a/mindee/error/mindee_http_error.py b/mindee/error/mindee_http_error.py index 7d62d073..131a6538 100644 --- a/mindee/error/mindee_http_error.py +++ b/mindee/error/mindee_http_error.py @@ -1,4 +1,4 @@ -from typing import Union +from typing import Optional, Union from mindee.error.mindee_error import MindeeError from mindee.parsing.common.string_dict import StringDict @@ -8,9 +8,9 @@ class MindeeHTTPError(RuntimeError): """An exception relating to HTTP calls.""" status_code: int - api_code: str - api_details: str - api_message: str + api_code: Optional[str] + api_details: Optional[str] + api_message: Optional[str] def __init__(self, http_error: StringDict, url: str, code: int) -> None: """ diff --git a/mindee/extraction/pdf_extractor/pdf_extractor.py b/mindee/extraction/pdf_extractor/pdf_extractor.py index 91685be2..1a2023ca 100644 --- a/mindee/extraction/pdf_extractor/pdf_extractor.py +++ b/mindee/extraction/pdf_extractor/pdf_extractor.py @@ -91,9 +91,7 @@ def extract_invoices( if not isinstance(page_indexes[0], InvoiceSplitterV1PageGroup): return self.extract_sub_documents(page_indexes) # type: ignore if not strict: - indexes_as_list = [ - page_index.page_indexes for page_index in page_indexes # type: ignore - ] + indexes_as_list = [page_index.page_indexes for page_index in page_indexes] # type: ignore return self.extract_sub_documents(indexes_as_list) correct_page_indexes: List[List[int]] = [] current_list: List[int] = [] diff --git a/tests/product/generated/test_generated_v1.py b/tests/product/generated/test_generated_v1.py index 84fee9a4..5caadbab 100644 --- a/tests/product/generated/test_generated_v1.py +++ b/tests/product/generated/test_generated_v1.py @@ -487,13 +487,13 @@ def test_invoice_v4_complete_doc(invoice_v4_complete_doc) -> None: invoice_v4_complete_doc.inference.prediction.fields["line_items"] .values[0] .product_code - == None + is None ) assert ( invoice_v4_complete_doc.inference.prediction.fields["line_items"] .values[0] .quantity - == None + is None ) assert ( invoice_v4_complete_doc.inference.prediction.fields["line_items"] @@ -505,13 +505,13 @@ def test_invoice_v4_complete_doc(invoice_v4_complete_doc) -> None: invoice_v4_complete_doc.inference.prediction.fields["line_items"] .values[0] .tax_amount - == None + is None ) assert ( invoice_v4_complete_doc.inference.prediction.fields["line_items"] .values[0] .tax_rate - == None + is None ) assert ( invoice_v4_complete_doc.inference.prediction.fields["line_items"] @@ -523,7 +523,7 @@ def test_invoice_v4_complete_doc(invoice_v4_complete_doc) -> None: invoice_v4_complete_doc.inference.prediction.fields["line_items"] .values[0] .unit_price - == None + is None ) assert ( invoice_v4_complete_doc.inference.prediction.fields["line_items"] @@ -705,19 +705,19 @@ def test_invoice_v4_page0(invoice_v4_page_0) -> None: == "S)BOIE 5X500 FEUILLES A4" ) assert ( - invoice_v4_page_0.prediction.fields["line_items"].values[0].product_code == None + invoice_v4_page_0.prediction.fields["line_items"].values[0].product_code is None ) - assert invoice_v4_page_0.prediction.fields["line_items"].values[0].quantity == None + assert invoice_v4_page_0.prediction.fields["line_items"].values[0].quantity is None assert ( - invoice_v4_page_0.prediction.fields["line_items"].values[0].tax_amount == None + invoice_v4_page_0.prediction.fields["line_items"].values[0].tax_amount is None ) - assert invoice_v4_page_0.prediction.fields["line_items"].values[0].tax_rate == None + assert invoice_v4_page_0.prediction.fields["line_items"].values[0].tax_rate is None assert ( invoice_v4_page_0.prediction.fields["line_items"].values[0].total_amount == "2.63" ) assert ( - invoice_v4_page_0.prediction.fields["line_items"].values[0].unit_price == None + invoice_v4_page_0.prediction.fields["line_items"].values[0].unit_price is None ) assert isinstance(