A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Let ruff autofix some things from the newest version
Trenton H70f3f9836309
diff --git a/docker/wait-for-redis.py b/docker/wait-for-redis.pyindex d6ce5c639..41df5a08b 100755--- a/docker/wait-for-redis.py+++ b/docker/wait-for-redis.py@@ -28,7 +28,7 @@ if __name__ == "__main__":except Exception as e:print(f"Redis ping #{attempt} failed.\n"- f"Error: {str(e)}.\n"+ f"Error: {e!s}.\n"f"Waiting {RETRY_SLEEP_SECONDS}s",flush=True,)diff --git a/src/documents/barcodes.py b/src/documents/barcodes.pyindex dfeac545b..f3d59bc5b 100644--- a/src/documents/barcodes.py+++ b/src/documents/barcodes.py@@ -121,7 +121,7 @@ class BarcodeReader:if barcode.text:barcodes.append(barcode.text)logger.debug(- f"Barcode of type {str(barcode.format)} found: {barcode.text}",+ f"Barcode of type {barcode.format} found: {barcode.text}",)return barcodes@@ -141,7 +141,7 @@ class BarcodeReader:decoded_barcode = barcode.data.decode("utf-8")barcodes.append(decoded_barcode)logger.debug(- f"Barcode of type {str(barcode.type)} found: {decoded_barcode}",+ f"Barcode of type {barcode.type} found: {decoded_barcode}",)return barcodes@@ -348,7 +348,7 @@ class BarcodeReader:for idx, document_path in enumerate(doc_paths):if override_name is not None:- newname = f"{str(idx)}_{override_name}"+ newname = f"{idx}_{override_name}"dest = save_to_dir / newnameelse:dest = save_to_dirdiff --git a/src/documents/signals/handlers.py b/src/documents/signals/handlers.pyindex 40765443b..4a39d98ea 100644--- a/src/documents/signals/handlers.py+++ b/src/documents/signals/handlers.py@@ -346,7 +346,7 @@ def cleanup_document_deletion(sender, instance, using, **kwargs):logger.debug(f"Deleted file {filename}.")except OSError as e:logger.warning(- f"While deleting document {str(instance)}, the file "+ f"While deleting document {instance!s}, the file "f"{filename} could not be deleted: {e}",)@@ -369,13 +369,13 @@ class CannotMoveFilesException(Exception):def validate_move(instance, old_path, new_path):if not os.path.isfile(old_path):# Can't do anything if the old file does not exist anymore.- logger.fatal(f"Document {str(instance)}: File {old_path} has gone.")+ logger.fatal(f"Document {instance!s}: File {old_path} has gone.")raise CannotMoveFilesExceptionif os.path.isfile(new_path):# Can't do anything if the new file already exists. Skip updating file.logger.warning(- f"Document {str(instance)}: Cannot rename file "+ f"Document {instance!s}: Cannot rename file "f"since target path {new_path} already exists.",)raise CannotMoveFilesExceptiondiff --git a/src/documents/tasks.py b/src/documents/tasks.pyindex 1603a1359..d320875a0 100644--- a/src/documents/tasks.py+++ b/src/documents/tasks.py@@ -116,7 +116,7 @@ def consume_file({"type": "status_update", "data": payload},)except ConnectionError as e:- logger.warning(f"ConnectionError on status send: {str(e)}")+ logger.warning(f"ConnectionError on status send: {e!s}")# consuming stops here, since the original document with# the barcodes has been split and will be consumed separatelydiff --git a/src/documents/views.py b/src/documents/views.pyindex d60cf459d..cd69095fe 100644--- a/src/documents/views.py+++ b/src/documents/views.py@@ -519,7 +519,7 @@ class DocumentViewSet(try:return Response(self.getNotes(doc))except Exception as e:- logger.warning(f"An error occurred retrieving notes: {str(e)}")+ logger.warning(f"An error occurred retrieving notes: {e!s}")return Response({"error": "Error retreiving notes, check logs for more detail."},)@@ -538,7 +538,7 @@ class DocumentViewSet(return Response(self.getNotes(doc))except Exception as e:- logger.warning(f"An error occurred saving note: {str(e)}")+ logger.warning(f"An error occurred saving note: {e!s}")return Response({"error": "Error saving note, check logs for more detail.",@@ -628,7 +628,7 @@ class UnifiedSearchViewSet(DocumentViewSet):except NotFound:raiseexcept Exception as e:- logger.warning(f"An error occurred listing search results: {str(e)}")+ logger.warning(f"An error occurred listing search results: {e!s}")return HttpResponseBadRequest("Error listing search results, check logs for more detail.",)@@ -699,7 +699,7 @@ class BulkEditView(GenericAPIView):result = method(documents, **parameters)return Response({"result": result})except Exception as e:- logger.warning(f"An error occurred performing bulk edit: {str(e)}")+ logger.warning(f"An error occurred performing bulk edit: {e!s}")return HttpResponseBadRequest("Error performing bulk edit, check logs for more detail.",)diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.pyindex bfb306e5a..65768d3c2 100644--- a/src/paperless_mail/mail.py+++ b/src/paperless_mail/mail.py@@ -544,7 +544,7 @@ class MailAccountHandler(LoggingMixin):criterias = make_criterias(rule, supports_gmail_labels)self.log.debug(- f"Rule {rule}: Searching folder with criteria {str(criterias)}",+ f"Rule {rule}: Searching folder with criteria {criterias}",)try:diff --git a/src/paperless_tesseract/parsers.py b/src/paperless_tesseract/parsers.pyindex b6a721b2f..c6d066fbe 100644--- a/src/paperless_tesseract/parsers.py+++ b/src/paperless_tesseract/parsers.py@@ -335,7 +335,7 @@ class RasterisedDocumentParser(DocumentParser):self.text = text_originalexcept (NoTextFoundException, InputFileError) as e:self.log.warning(- f"Encountered an error while running OCR: {str(e)}. "+ f"Encountered an error while running OCR: {e!s}. "f"Attempting force OCR to get the text.",)@@ -370,11 +370,11 @@ class RasterisedDocumentParser(DocumentParser):except Exception as e:# If this fails, we have a serious issue at hand.- raise ParseError(f"{e.__class__.__name__}: {str(e)}") from e+ raise ParseError(f"{e.__class__.__name__}: {e!s}") from eexcept Exception as e:# Anything else is probably serious.- raise ParseError(f"{e.__class__.__name__}: {str(e)}") from e+ raise ParseError(f"{e.__class__.__name__}: {e!s}") from e# As a last resort, if we still don't have any text for any reason,# try to extract the text from the original document.