diff --git a/document-parser/conftest.py b/document-parser/conftest.py index 60a2633..ddf789c 100644 --- a/document-parser/conftest.py +++ b/document-parser/conftest.py @@ -1,3 +1 @@ - - pytest_plugins = ["pytest_asyncio"] diff --git a/document-parser/domain/bbox.py b/document-parser/domain/bbox.py index 41530a7..4804df9 100644 --- a/document-parser/domain/bbox.py +++ b/document-parser/domain/bbox.py @@ -43,7 +43,11 @@ def to_topleft_list(bbox: BoundingBox, page_height: float) -> list[float]: if right <= left or bottom <= top: logger.debug( "Degenerate bbox skipped: [%.1f, %.1f, %.1f, %.1f] (page_height=%.1f)", - left, top, right, bottom, page_height, + left, + top, + right, + bottom, + page_height, ) return list(EMPTY_BBOX) diff --git a/document-parser/infra/serve_converter.py b/document-parser/infra/serve_converter.py index d85e4a5..410e497 100644 --- a/document-parser/infra/serve_converter.py +++ b/document-parser/infra/serve_converter.py @@ -71,7 +71,9 @@ class ServeConverter: return headers async def convert( - self, file_path: str, options: ConversionOptions, + self, + file_path: str, + options: ConversionOptions, ) -> ConversionResult: """Convert a document by uploading it to Docling Serve.""" path = Path(file_path) @@ -202,7 +204,9 @@ def _add_element(item: dict, pages: dict[int, PageDetail]) -> None: page_no = prov.get("page_no", 1) if page_no not in pages: pages[page_no] = PageDetail( - page_number=page_no, width=612.0, height=792.0, + page_number=page_no, + width=612.0, + height=792.0, ) bbox_data = prov.get("bbox", {}) diff --git a/document-parser/infra/settings.py b/document-parser/infra/settings.py index 0b19c54..348f551 100644 --- a/document-parser/infra/settings.py +++ b/document-parser/infra/settings.py @@ -14,7 +14,9 @@ class Settings: conversion_timeout: int = 600 upload_dir: str = "./uploads" db_path: str = "./data/docling_studio.db" - cors_origins: list[str] = field(default_factory=lambda: ["http://localhost:3000", "http://localhost:5173"]) + cors_origins: list[str] = field( + default_factory=lambda: ["http://localhost:3000", "http://localhost:5173"] + ) @classmethod def from_env(cls) -> Settings: diff --git a/document-parser/persistence/document_repo.py b/document-parser/persistence/document_repo.py index 868b24d..623e36a 100644 --- a/document-parser/persistence/document_repo.py +++ b/document-parser/persistence/document_repo.py @@ -28,8 +28,15 @@ async def insert(doc: Document) -> None: await db.execute( """INSERT INTO documents (id, filename, content_type, file_size, page_count, storage_path, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)""", - (doc.id, doc.filename, doc.content_type, doc.file_size, - doc.page_count, doc.storage_path, str(doc.created_at)), + ( + doc.id, + doc.filename, + doc.content_type, + doc.file_size, + doc.page_count, + doc.storage_path, + str(doc.created_at), + ), ) await db.commit() diff --git a/document-parser/tests/test_bbox.py b/document-parser/tests/test_bbox.py index 9ffe67c..f201a73 100644 --- a/document-parser/tests/test_bbox.py +++ b/document-parser/tests/test_bbox.py @@ -14,6 +14,7 @@ from domain.bbox import EMPTY_BBOX, to_topleft_list # Standard conversions # --------------------------------------------------------------------------- + class TestToTopleftListStandard: """Normal bbox conversions (happy path).""" @@ -29,10 +30,10 @@ class TestToTopleftListStandard: result = to_topleft_list(bbox, page_height=792.0) # After conversion: new_t = 792 - 700 = 92, new_b = 792 - 600 = 192 - assert result[0] == 50 # l unchanged - assert result[1] == pytest.approx(92.0) # t = page_height - old_t - assert result[2] == 200 # r unchanged - assert result[3] == pytest.approx(192.0) # b = page_height - old_b + assert result[0] == 50 # l unchanged + assert result[1] == pytest.approx(92.0) # t = page_height - old_t + assert result[2] == 200 # r unchanged + assert result[3] == pytest.approx(192.0) # b = page_height - old_b def test_result_has_positive_dimensions(self): """Converted bbox should always have b > t (positive height).""" @@ -60,6 +61,7 @@ class TestToTopleftListStandard: # Page format variations # --------------------------------------------------------------------------- + class TestPageFormats: """Verify correct conversion across different page sizes.""" @@ -105,6 +107,7 @@ class TestPageFormats: # Degenerate / edge-case bboxes # --------------------------------------------------------------------------- + class TestDegenerateBboxes: """Bboxes that are invalid or degenerate should return EMPTY_BBOX.""" @@ -151,6 +154,7 @@ class TestDegenerateBboxes: # Precision and boundary values # --------------------------------------------------------------------------- + class TestPrecision: """Floating-point precision and edge values.""" diff --git a/document-parser/tests/test_repos.py b/document-parser/tests/test_repos.py index 8e89c54..44ebc17 100644 --- a/document-parser/tests/test_repos.py +++ b/document-parser/tests/test_repos.py @@ -1,6 +1,5 @@ """Tests for persistence repositories using a temporary SQLite database.""" - import pytest from domain.models import AnalysisJob, AnalysisStatus, Document diff --git a/document-parser/tests/test_schemas.py b/document-parser/tests/test_schemas.py index c5bb94b..1352802 100644 --- a/document-parser/tests/test_schemas.py +++ b/document-parser/tests/test_schemas.py @@ -1,6 +1,5 @@ """Tests for API schemas — camelCase serialization and validation.""" - import pytest from api.schemas import ( @@ -97,7 +96,10 @@ class TestPipelineOptionsRequest: def test_custom_values(self): opts = PipelineOptionsRequest( - do_ocr=False, table_mode="fast", do_code_enrichment=True, images_scale=2.0, + do_ocr=False, + table_mode="fast", + do_code_enrichment=True, + images_scale=2.0, ) assert opts.do_ocr is False assert opts.table_mode == "fast"