A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
use imported List fail test if non-existing dir exists
Florian Brandes08fbcf515844
diff --git a/src/documents/tasks.py b/src/documents/tasks.pyindex 7bd212399..42d50549d 100644--- a/src/documents/tasks.py+++ b/src/documents/tasks.py@@ -2,6 +2,7 @@ import loggingimport osimport shutilimport tempfile+from typing import List # for type hinting. Can be removed, if only Python >3.8 is usedimport tqdmfrom asgiref.sync import async_to_sync@@ -24,6 +25,7 @@ from pikepdf import Pdffrom pyzbar import pyzbarfrom whoosh.writing import AsyncWriter+logger = logging.getLogger("paperless.tasks")@@ -70,7 +72,7 @@ def train_classifier():logger.warning("Classifier error: " + str(e))-def barcode_reader(image) -> list[str]:+def barcode_reader(image) -> List[str]:"""Read any barcodes contained in imageReturns a list containing all found barcodes@@ -91,7 +93,7 @@ def barcode_reader(image) -> list[str]:return barcodes-def scan_file_for_separating_barcodes(filepath: str) -> list[int]:+def scan_file_for_separating_barcodes(filepath: str) -> List[int]:"""Scan the provided file for page separating barcodesReturns a list of pagenumbers, which separate the file@@ -108,7 +110,7 @@ def scan_file_for_separating_barcodes(filepath: str) -> list[int]:return separator_page_numbers-def separate_pages(filepath: str, pages_to_split_on: list[int]) -> list[str]:+def separate_pages(filepath: str, pages_to_split_on: List[int]) -> List[str]:"""Separate the provided file on the pages_to_split_on.The pages which are defined by page_numbers will be removed.diff --git a/src/documents/tests/test_tasks.py b/src/documents/tests/test_tasks.pyindex 1b59b7109..46be59d53 100644--- a/src/documents/tests/test_tasks.py+++ b/src/documents/tests/test_tasks.py@@ -313,7 +313,7 @@ class TestTasks(DirectoriesMixin, TestCase):)nonexistingdir = "/nowhere"if os.path.isdir(nonexistingdir):- self.skipTest("non-existing dir exists")+ self.fail("non-existing dir exists")else:with self.assertLogs("paperless.tasks", level="WARNING") as cm:tasks.save_to_dir(test_file, target_dir=nonexistingdir)