From 44496a54e62bc0d64d6c91c9a3eb3e4899edea23 Mon Sep 17 00:00:00 2001 From: wandering Date: Thu, 2 Jul 2026 18:51:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A1=A5=E5=85=85=20=5F=5Finit=5F=5F.py?= =?UTF-8?q?=20=E5=AF=BC=E5=87=BA=E7=AC=A6=E5=8F=B7=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=B5=8B=E8=AF=95=E5=AF=BC=E5=85=A5=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - src/core/extraction/__init__.py: 导出 _image_to_base64 - src/core/matching/__init__.py: 导出所有内部函数(_build_invoice_summary, _build_payment_records, _invoices_to_records, _match, _match_by_filename, _match_one_to_many, _match_one_to_one, _relative_tolerance, _safe_float) - src/infra/documents/__init__.py: 导出 INVOICE_LEVEL_COLUMNS, PAYMENT_RECORD_COLUMNS - tests/test_extractor.py: 修正 monkeypatch 路径为模块级引用 --- src/core/extraction/__init__.py | 2 ++ src/core/matching/__init__.py | 26 ++++++++++++++++++++++++-- src/infra/documents/__init__.py | 4 ++++ tests/test_extractor.py | 10 +++++----- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/core/extraction/__init__.py b/src/core/extraction/__init__.py index 8cbd4ae..166edc6 100644 --- a/src/core/extraction/__init__.py +++ b/src/core/extraction/__init__.py @@ -11,6 +11,7 @@ from .extractor import ( ) from .llm_extractor import ( CACHE_DIR_NAME, + _image_to_base64, build_extraction_user_message, extract_document, extract_normal_info, @@ -25,6 +26,7 @@ from .llm_extractor import ( __all__ = [ "CACHE_DIR_NAME", + "_image_to_base64", "build_extraction_user_message", "extract_document", "extract_normal_info", diff --git a/src/core/matching/__init__.py b/src/core/matching/__init__.py index 1f83b01..67599c0 100644 --- a/src/core/matching/__init__.py +++ b/src/core/matching/__init__.py @@ -3,6 +3,28 @@ 提供发票与支付记录的金额匹配功能。 """ -from .matcher import match_invoices_to_cards +from .matcher import ( + _build_invoice_summary, + _build_payment_records, + _invoices_to_records, + _match, + _match_by_filename, + _match_one_to_many, + _match_one_to_one, + _relative_tolerance, + _safe_float, + match_invoices_to_cards, +) -__all__ = ["match_invoices_to_cards"] +__all__ = [ + "_build_invoice_summary", + "_build_payment_records", + "_invoices_to_records", + "_match", + "_match_by_filename", + "_match_one_to_many", + "_match_one_to_one", + "_relative_tolerance", + "_safe_float", + "match_invoices_to_cards", +] diff --git a/src/infra/documents/__init__.py b/src/infra/documents/__init__.py index 1eb5675..4598a09 100644 --- a/src/infra/documents/__init__.py +++ b/src/infra/documents/__init__.py @@ -10,6 +10,8 @@ from .consumable import ( ) from .invoice import ( CACHE_DIR_NAME, + INVOICE_LEVEL_COLUMNS, + PAYMENT_RECORD_COLUMNS, classify_invoice_batch, load_csv, load_invoice_csv, @@ -20,6 +22,8 @@ from .invoice import ( __all__ = [ "CACHE_DIR_NAME", + "INVOICE_LEVEL_COLUMNS", + "PAYMENT_RECORD_COLUMNS", "classify_invoice_batch", "load_csv", "load_invoice_csv", diff --git a/tests/test_extractor.py b/tests/test_extractor.py index f5eaa02..6283323 100644 --- a/tests/test_extractor.py +++ b/tests/test_extractor.py @@ -129,7 +129,7 @@ class TestExtractInvoices: } ] - monkeypatch.setattr("src.core.matching.matcher.match_invoices_to_cards", fake_match) + monkeypatch.setattr("src.core.extraction.extractor.match_invoices_to_cards", fake_match) records, apps, groups = extract_invoices(str(tmp_path)) @@ -194,7 +194,7 @@ class TestExtractInvoices: }, ] - monkeypatch.setattr("src.core.matching.matcher.match_invoices_to_cards", fake_match) + monkeypatch.setattr("src.core.extraction.extractor.match_invoices_to_cards", fake_match) records, apps, groups = extract_invoices(str(tmp_path)) @@ -241,7 +241,7 @@ class TestExtractInvoices: } ] - monkeypatch.setattr("src.core.matching.matcher.match_invoices_to_cards", fake_match) + monkeypatch.setattr("src.core.extraction.extractor.match_invoices_to_cards", fake_match) records, apps, groups = extract_invoices(str(tmp_path)) @@ -283,7 +283,7 @@ class TestExtractInvoices: } ] - monkeypatch.setattr("src.core.matching.matcher.match_invoices_to_cards", fake_match) + monkeypatch.setattr("src.core.extraction.extractor.match_invoices_to_cards", fake_match) records, apps, groups = extract_invoices(str(tmp_path)) @@ -324,7 +324,7 @@ class TestExtractInvoices: } ] - monkeypatch.setattr("src.core.matching.matcher.match_invoices_to_cards", fake_match) + monkeypatch.setattr("src.core.extraction.extractor.match_invoices_to_cards", fake_match) records, apps, groups = extract_invoices(str(tmp_path))