Skip to content

Commit 31f79e0

Browse files
⬆️ upgrade dependencies and add more tools
1 parent 2853658 commit 31f79e0

7 files changed

Lines changed: 106 additions & 24 deletions

File tree

.github/dependabot.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
version: 2
2+
3+
updates:
4+
- package-ecosystem: "pip"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
time: "09:00"
10+
timezone: "Europe/Paris"
11+
open-pull-requests-limit: 8
12+
commit-message:
13+
prefix: "chore(deps)"
14+
groups:
15+
runtime-dependencies:
16+
patterns:
17+
- "pytz"
18+
- "requests"
19+
optional-dependencies:
20+
patterns:
21+
- "pypdfium2"
22+
- "Pillow"
23+
test-dependencies:
24+
patterns:
25+
- "pytest"
26+
- "pytest-cov"
27+
- "toml"
28+
lint-dependencies:
29+
patterns:
30+
- "pylint"
31+
- "pre-commit"
32+
- "types-*"
33+
docs-dependencies:
34+
patterns:
35+
- "sphinx"
36+
- "sphinx-*"
37+
build-dependencies:
38+
patterns:
39+
- "build"
40+
- "twine"
41+
42+
- package-ecosystem: "github-actions"
43+
directory: "/"
44+
schedule:
45+
interval: "weekly"
46+
day: "monday"
47+
time: "09:30"
48+
timezone: "Europe/Paris"
49+
open-pull-requests-limit: 3
50+
commit-message:
51+
prefix: "chore(ci)"
52+
groups:
53+
github-actions:
54+
patterns:
55+
- "*"
56+
57+
- package-ecosystem: "pre-commit"
58+
directory: "/"
59+
schedule:
60+
interval: "weekly"
61+
day: "monday"
62+
time: "10:00"
63+
timezone: "Europe/Paris"
64+
open-pull-requests-limit: 3
65+
commit-message:
66+
prefix: "chore(pre-commit)"
67+
groups:
68+
pre-commit-hooks:
69+
patterns:
70+
- "*"

.github/workflows/_publish-docs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,14 @@ jobs:
3939
cd ./docs
4040
make html
4141
42+
- name: Sphinx make linkcheck
43+
run: |
44+
cd ./docs
45+
make linkcheck
46+
4247
- name: Deploy
4348
uses: peaceiris/actions-gh-pages@v4
49+
if: success()
4450
with:
4551
github_token: ${{ secrets.GITHUB_TOKEN }}
4652
publish_dir: ./docs/_build/html

.pre-commit-config.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ repos:
66
args: [ --fix, --exit-non-zero-on-fix]
77
- id: ruff-format
88

9-
- repo: https://github.com/gitleaks/gitleaks
10-
rev: v8.30.0
9+
- repo: https://github.com/betterleaks/betterleaks
10+
rev: v1.3.1
1111
hooks:
12-
- id: gitleaks
12+
- id: betterleaks
1313

1414
- repo: https://github.com/PyCQA/pylint
15-
rev: v3.3.9
15+
rev: v4.0.5
1616
hooks:
1717
- id: pylint
1818
name: pylint
@@ -22,6 +22,11 @@ repos:
2222
args: [
2323
"-j2"
2424
]
25+
- repo: https://github.com/pypa/pip-audit
26+
rev: v2.10.0
27+
hooks:
28+
- id: pip-audit
29+
args: ["."]
2530

2631
- repo: https://github.com/pre-commit/mirrors-mypy
2732
rev: v1.18.2

mindee/image/image_extractor.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def attach_image_as_new_file( # type: ignore
2121
:params input_buffer: Input buffer.
2222
:return: A PdfDocument handle.
2323
"""
24-
# Create a new page in the PdfDocument
2524
input_buffer.seek(0)
2625
image = Image.open(input_buffer)
2726
image.convert("RGB")
@@ -32,8 +31,7 @@ def attach_image_as_new_file( # type: ignore
3231

3332
image_pdf = pdfium.PdfImage.new(pdf)
3433
image_pdf.load_jpeg(image_buffer)
35-
width, height = image_pdf.get_size()
36-
34+
width, height = image.width, image.height
3735
matrix = pdfium.PdfMatrix().scale(width, height)
3836
image_pdf.set_matrix(matrix)
3937

mindee/pdf/pdf_compressor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ def _collect_images_as_pdf(image_list: List[bytes]) -> pdfium.PdfDocument: # ty
213213
pdf_image = pdfium.PdfImage.new(out_pdf)
214214
pdf_image.load_jpeg(io.BytesIO(image_bytes))
215215

216-
width, height = pdf_image.get_size()
216+
metadata = pdf_image.get_metadata()
217+
width, height = metadata.width, metadata.height
217218
page = out_pdf.new_page(width, height)
218219
page.insert_obj(pdf_image)
219220
page.gen_content()

pyproject.toml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ classifiers = [
2828
requires-python = ">=3.10"
2929

3030
dependencies = [
31-
"pypdfium2>=4.0,<4.30.1",
32-
"Pillow>=9.5.0",
33-
"pytz>=2023.3",
34-
"requests>=2.31.0",
31+
"pypdfium2>=4.0,<6.0",
32+
"Pillow>=12.2.0",
33+
"pytz>=2026.2",
34+
"requests>=2.34.2",
3535
]
3636

3737
[project.urls]
@@ -43,20 +43,21 @@ Changelog = "https://github.com/mindee/mindee-api-python/blob/main/CHANGELOG.md"
4343

4444
[project.optional-dependencies]
4545
lint = [
46-
"pylint==3.3.9",
47-
"pre-commit~=3.6.0",
48-
"types-pytz>=2024.2",
49-
"types-requests>=2.31",
46+
"pylint==4.0.5",
47+
"pre-commit~=4.6.0",
48+
"types-pytz>=2026.2.0.20260518",
49+
"types-requests>=2.33.0.20260518",
50+
"pip-audit>=2.10.0",
5051
]
5152
test = [
5253
"toml~=0.10.2",
53-
"pytest~=8.0.0",
54-
"pytest-cov~=5.0",
54+
"pytest~=9.0.3",
55+
"pytest-cov~=7.1.0",
5556
]
5657
docs = [
57-
"sphinx~=7.3",
58-
"sphinx_rtd_theme~=2.0",
59-
"sphinx-autodoc-typehints~=2.2",
58+
"sphinx~=9.1.0",
59+
"sphinx_rtd_theme~=3.1.0",
60+
"sphinx-autodoc-typehints~=3.10.4",
6061
]
6162
build = [
6263
"build",

tests/v2/file_operations/test_crop_operation_integration.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ def test_image_should_extract_crops():
5151
)
5252
check_findoc_return(invoice_0)
5353
extracted_images.save_all_to_disk(OUTPUT_DIR)
54-
# note: flaky
55-
assert os.path.getsize(OUTPUT_DIR / "crop_001.jpg") in (187601, 199685)
56-
assert os.path.getsize(OUTPUT_DIR / "crop_002.jpg") in (197978, 199433)
54+
crop1size = os.path.getsize(OUTPUT_DIR / "crop_001.jpg")
55+
crop2size = os.path.getsize(OUTPUT_DIR / "crop_002.jpg")
56+
assert 187601 <= crop1size <= 199685
57+
assert crop2size == 197978
5758

5859

5960
@pytest.fixture(scope="module", autouse=True)

0 commit comments

Comments
 (0)