From 3bcbd052526dc9bb94cd49ce0bba489cb0f1727b Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Thu, 20 Apr 2023 08:10:17 -0700 Subject: [PATCH] Fixes ruff not running isort against the codebase --- .ruff.toml | 2 +- src/documents/apps.py | 16 +++++++--------- src/documents/bulk_edit.py | 1 + src/documents/checks.py | 1 + src/documents/classifier.py | 4 ++-- src/documents/consumer.py | 2 +- src/documents/file_handling.py | 1 + src/documents/filters.py | 1 - src/documents/index.py | 7 ++++--- .../management/commands/decrypt_documents.py | 1 + .../management/commands/document_archiver.py | 2 +- .../management/commands/document_consumer.py | 8 +++++--- .../management/commands/document_exporter.py | 8 ++++---- .../management/commands/document_importer.py | 8 ++++---- .../management/commands/document_index.py | 1 + .../management/commands/document_renamer.py | 1 + .../management/commands/document_retagger.py | 3 +-- .../commands/document_sanity_checker.py | 1 + .../commands/document_thumbnails.py | 2 +- .../management/commands/manage_superuser.py | 1 - src/documents/matching.py | 1 - src/documents/migrations/0001_initial.py | 3 ++- .../migrations/0002_auto_20151226_1316.py | 3 ++- src/documents/migrations/0003_sender.py | 7 +++---- .../migrations/0004_auto_20160114_1844.py | 3 ++- .../migrations/0006_auto_20160123_0430.py | 3 ++- .../migrations/0007_auto_20160126_2114.py | 3 ++- .../migrations/0008_document_file_type.py | 3 ++- .../migrations/0009_auto_20160214_0040.py | 3 ++- src/documents/migrations/0010_log.py | 3 ++- .../migrations/0012_auto_20160305_0040.py | 2 +- .../migrations/0013_auto_20160325_2111.py | 3 ++- .../migrations/0014_document_checksum.py | 5 +++-- .../0015_add_insensitive_to_match.py | 3 ++- .../migrations/0016_auto_20170325_1558.py | 3 ++- .../migrations/0017_auto_20170512_0507.py | 3 ++- .../migrations/0018_auto_20170715_1712.py | 3 ++- .../migrations/0020_document_added.py | 3 ++- .../migrations/0021_document_storage_type.py | 3 ++- .../migrations/0022_auto_20181007_1420.py | 3 ++- .../0023_document_current_filename.py | 3 ++- .../migrations/1000_update_paperless_all.py | 3 ++- .../migrations/1002_auto_20201111_1105.py | 3 ++- src/documents/migrations/1003_mime_types.py | 3 ++- src/documents/migrations/1005_checksums.py | 3 ++- .../1007_savedview_savedviewfilterrule.py | 5 +++-- .../migrations/1008_auto_20201216_1736.py | 2 +- .../migrations/1010_auto_20210101_2159.py | 3 ++- .../migrations/1011_auto_20210101_2340.py | 5 +++-- .../migrations/1012_fix_archive_files.py | 15 +++++++-------- .../migrations/1013_migrate_tag_colour.py | 3 ++- .../migrations/1014_auto_20210228_1614.py | 3 ++- .../migrations/1015_remove_null_characters.py | 1 - .../migrations/1016_auto_20210317_1351.py | 3 ++- ...017_alter_savedviewfilterrule_rule_type.py | 3 ++- .../1018_alter_savedviewfilterrule_value.py | 3 ++- .../1019_storagepath_document_storage_path.py | 3 ++- src/documents/migrations/1019_uisettings.py | 5 +++-- .../1021_webp_thumbnail_conversion.py | 1 + .../migrations/1022_paperlesstask.py | 3 ++- src/documents/migrations/1023_add_comments.py | 3 ++- .../1024_document_original_filename.py | 3 ++- ...025_alter_savedviewfilterrule_rule_type.py | 3 ++- .../migrations/1026_transition_to_celery.py | 3 ++- ...e_paperlesstask_attempted_task_and_more.py | 3 ++- ...29_alter_document_archive_serial_number.py | 3 ++- ...1030_alter_paperlesstask_task_file_name.py | 3 ++- ...dview_user_correspondent_owner_and_more.py | 5 +++-- ...rrespondent_matching_algorithm_and_more.py | 3 ++- ...type_options_alter_tag_options_and_more.py | 3 ++- ...034_alter_savedviewfilterrule_rule_type.py | 3 ++- .../migrations/1035_rename_comment_note.py | 2 +- src/documents/models.py | 1 + src/documents/parsers.py | 1 + src/documents/sanity_checker.py | 3 ++- src/documents/serialisers.py | 16 +++++++--------- src/documents/tasks.py | 8 ++++---- src/documents/tests/test_admin.py | 1 + src/documents/tests/test_api.py | 11 ++++++----- src/documents/tests/test_barcodes.py | 5 +++-- src/documents/tests/test_checks.py | 3 ++- src/documents/tests/test_classifier.py | 3 ++- src/documents/tests/test_consumer.py | 7 ++++--- src/documents/tests/test_date_parsing.py | 3 ++- src/documents/tests/test_document_model.py | 2 +- src/documents/tests/test_file_handling.py | 2 +- src/documents/tests/test_importer.py | 11 ++++++----- src/documents/tests/test_index.py | 1 + src/documents/tests/test_management.py | 4 ++-- .../tests/test_management_consumer.py | 5 +++-- .../tests/test_management_exporter.py | 3 ++- .../tests/test_management_retagger.py | 1 + .../tests/test_management_superuser.py | 1 + .../tests/test_management_thumbnails.py | 1 + src/documents/tests/test_matchables.py | 2 +- .../tests/test_migration_archive_files.py | 2 +- .../tests/test_migration_mime_type.py | 1 + .../tests/test_migration_webp_conversion.py | 1 + src/documents/tests/test_models.py | 1 + src/documents/tests/test_parsers.py | 3 ++- src/documents/tests/test_sanity_check.py | 1 + src/documents/tests/test_task_signals.py | 3 ++- src/documents/tests/test_tasks.py | 1 + src/documents/tests/test_views.py | 2 +- src/documents/tests/utils.py | 3 ++- src/paperless/apps.py | 1 + src/paperless/asgi.py | 3 ++- src/paperless/checks.py | 2 +- src/paperless/filters.py | 1 + src/paperless/middleware.py | 1 + src/paperless/tests/test_checks.py | 3 ++- src/paperless/tests/test_settings.py | 3 ++- src/paperless/tests/test_signals.py | 1 + src/paperless/tests/test_websockets.py | 4 ++-- src/paperless/urls.py | 5 +++-- src/paperless/views.py | 9 +++++---- src/paperless_mail/admin.py | 1 + src/paperless_mail/apps.py | 1 + src/paperless_mail/mail.py | 19 ++++++++++--------- .../management/commands/mail_fetcher.py | 1 + src/paperless_mail/migrations/0001_initial.py | 3 ++- .../migrations/0003_auto_20201118_1940.py | 3 ++- .../migrations/0004_mailrule_order.py | 3 ++- .../migrations/0005_help_texts.py | 3 ++- .../migrations/0006_auto_20210101_2340.py | 3 ++- .../migrations/0007_auto_20210106_0138.py | 3 ++- .../migrations/0008_auto_20210516_0940.py | 3 ++- ...r_mailrule_action_alter_mailrule_folder.py | 3 ++- .../migrations/0009_mailrule_assign_tags.py | 3 ++- .../0012_alter_mailrule_assign_tags.py | 3 ++- .../migrations/0014_alter_mailrule_action.py | 3 ++- .../migrations/0015_alter_mailrule_action.py | 3 ++- .../0016_mailrule_consumption_scope.py | 3 ++- .../0017_mailaccount_owner_mailrule_owner.py | 5 +++-- .../migrations/0018_processedmail.py | 5 +++-- .../migrations/0019_mailrule_filter_to.py | 3 ++- .../migrations/0020_mailaccount_is_token.py | 3 ++- .../0021_alter_mailaccount_password.py | 3 ++- src/paperless_mail/models.py | 3 ++- src/paperless_mail/parsers.py | 7 ++++--- src/paperless_mail/serialisers.py | 3 ++- src/paperless_mail/tasks.py | 1 + src/paperless_mail/tests/test_api.py | 5 +++-- src/paperless_mail/tests/test_live_mail.py | 2 ++ src/paperless_mail/tests/test_mail.py | 11 ++++++----- src/paperless_mail/tests/test_parsers.py | 1 + src/paperless_mail/tests/test_parsers_live.py | 7 ++++--- src/paperless_mail/views.py | 19 ++++++++++--------- src/paperless_tesseract/apps.py | 1 + src/paperless_tesseract/checks.py | 2 +- src/paperless_tesseract/parsers.py | 10 ++++++---- src/paperless_tesseract/tests/test_checks.py | 3 ++- src/paperless_tesseract/tests/test_parser.py | 5 +++-- src/paperless_text/apps.py | 1 + src/paperless_text/parsers.py | 3 ++- src/paperless_text/tests/test_parser.py | 1 + src/paperless_tika/apps.py | 1 + src/paperless_tika/parsers.py | 7 ++++--- src/paperless_tika/tests/test_live_tika.py | 1 + src/paperless_tika/tests/test_tika_parser.py | 7 ++++--- 160 files changed, 347 insertions(+), 224 deletions(-) diff --git a/.ruff.toml b/.ruff.toml index 030c02b0a..0a20a7a2a 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -1,6 +1,6 @@ # https://beta.ruff.rs/docs/settings/ # https://beta.ruff.rs/docs/rules/ -select = ["F", "E", "W", "UP", "COM", "DJ", "EXE", "ISC", "ICN", "G201", "INP", "PIE", "RSE", "SIM", "TID", "PLC", "PLE", "RUF"] +extend-select = ["I", "W", "UP", "COM", "DJ", "EXE", "ISC", "ICN", "G201", "INP", "PIE", "RSE", "SIM", "TID", "PLC", "PLE", "RUF"] # TODO PTH ignore = ["DJ001", "SIM105"] fix = true diff --git a/src/documents/apps.py b/src/documents/apps.py index 9e0dd2554..31742342c 100644 --- a/src/documents/apps.py +++ b/src/documents/apps.py @@ -10,15 +10,13 @@ class DocumentsConfig(AppConfig): def ready(self): from .signals import document_consumption_finished - from .signals.handlers import ( - add_inbox_tags, - set_log_entry, - set_correspondent, - set_document_type, - set_tags, - set_storage_path, - add_to_index, - ) + from .signals.handlers import add_inbox_tags + from .signals.handlers import add_to_index + from .signals.handlers import set_correspondent + from .signals.handlers import set_document_type + from .signals.handlers import set_log_entry + from .signals.handlers import set_storage_path + from .signals.handlers import set_tags document_consumption_finished.connect(add_inbox_tags) document_consumption_finished.connect(set_correspondent) diff --git a/src/documents/bulk_edit.py b/src/documents/bulk_edit.py index 5908b55c8..c62283fee 100644 --- a/src/documents/bulk_edit.py +++ b/src/documents/bulk_edit.py @@ -1,6 +1,7 @@ import itertools from django.db.models import Q + from documents.models import Correspondent from documents.models import Document from documents.models import DocumentType diff --git a/src/documents/checks.py b/src/documents/checks.py index a014a0ac2..dd72080b6 100644 --- a/src/documents/checks.py +++ b/src/documents/checks.py @@ -6,6 +6,7 @@ from django.core.checks import register from django.core.exceptions import FieldError from django.db.utils import OperationalError from django.db.utils import ProgrammingError + from documents.signals import document_consumer_declaration diff --git a/src/documents/classifier.py b/src/documents/classifier.py index cbb8b1b90..e8ece34cc 100644 --- a/src/documents/classifier.py +++ b/src/documents/classifier.py @@ -10,6 +10,7 @@ from typing import List from typing import Optional from django.conf import settings + from documents.models import Document from documents.models import MatchingModel @@ -336,10 +337,9 @@ class DocumentClassifier: if settings.NLTK_LANGUAGE is not None and settings.NLTK_ENABLED: import nltk - - from nltk.tokenize import word_tokenize from nltk.corpus import stopwords from nltk.stem import SnowballStemmer + from nltk.tokenize import word_tokenize # Not really hacky, since it isn't private and is documented, but # set the search path for NLTK data to the single location it should be in diff --git a/src/documents/consumer.py b/src/documents/consumer.py index 12993a750..886e8d380 100644 --- a/src/documents/consumer.py +++ b/src/documents/consumer.py @@ -31,9 +31,9 @@ from .models import DocumentType from .models import FileInfo from .models import Tag from .parsers import DocumentParser +from .parsers import ParseError from .parsers import get_parser_class_for_mime_type from .parsers import parse_date -from .parsers import ParseError from .signals import document_consumption_finished from .signals import document_consumption_started diff --git a/src/documents/file_handling.py b/src/documents/file_handling.py index c046ae15a..e382d4965 100644 --- a/src/documents/file_handling.py +++ b/src/documents/file_handling.py @@ -7,6 +7,7 @@ import pathvalidate from django.conf import settings from django.template.defaultfilters import slugify from django.utils import timezone + from documents.models import Document logger = logging.getLogger("paperless.filehandling") diff --git a/src/documents/filters.py b/src/documents/filters.py index 271b91108..a75899d8f 100644 --- a/src/documents/filters.py +++ b/src/documents/filters.py @@ -11,7 +11,6 @@ from .models import Log from .models import StoragePath from .models import Tag - CHAR_KWARGS = ["istartswith", "iendswith", "icontains", "iexact"] ID_KWARGS = ["in", "exact"] INT_KWARGS = ["exact", "gt", "gte", "lt", "lte", "isnull"] diff --git a/src/documents/index.py b/src/documents/index.py index 1bf6a921d..ed364233c 100644 --- a/src/documents/index.py +++ b/src/documents/index.py @@ -6,8 +6,6 @@ from contextlib import contextmanager from dateutil.parser import isoparse from django.conf import settings from django.utils import timezone -from documents.models import Document -from documents.models import Note from guardian.shortcuts import get_users_with_perms from whoosh import classify from whoosh import highlight @@ -16,8 +14,8 @@ from whoosh.fields import BOOLEAN from whoosh.fields import DATETIME from whoosh.fields import KEYWORD from whoosh.fields import NUMERIC -from whoosh.fields import Schema from whoosh.fields import TEXT +from whoosh.fields import Schema from whoosh.highlight import HtmlFormatter from whoosh.index import create_in from whoosh.index import exists_in @@ -28,6 +26,9 @@ from whoosh.searching import ResultsPage from whoosh.searching import Searcher from whoosh.writing import AsyncWriter +from documents.models import Document +from documents.models import Note + logger = logging.getLogger("paperless.index") diff --git a/src/documents/management/commands/decrypt_documents.py b/src/documents/management/commands/decrypt_documents.py index 2cb98c4e1..8cb308e8e 100644 --- a/src/documents/management/commands/decrypt_documents.py +++ b/src/documents/management/commands/decrypt_documents.py @@ -3,6 +3,7 @@ import os from django.conf import settings from django.core.management.base import BaseCommand from django.core.management.base import CommandError + from documents.models import Document from paperless.db import GnuPG diff --git a/src/documents/management/commands/document_archiver.py b/src/documents/management/commands/document_archiver.py index fa78a1963..7484ed07a 100644 --- a/src/documents/management/commands/document_archiver.py +++ b/src/documents/management/commands/document_archiver.py @@ -6,10 +6,10 @@ import tqdm from django import db from django.conf import settings from django.core.management.base import BaseCommand + from documents.models import Document from documents.tasks import update_document_archive_file - logger = logging.getLogger("paperless.management.archiver") diff --git a/src/documents/management/commands/document_consumer.py b/src/documents/management/commands/document_consumer.py index 6cba1ea23..220948a3d 100644 --- a/src/documents/management/commands/document_consumer.py +++ b/src/documents/management/commands/document_consumer.py @@ -13,17 +13,19 @@ from typing import Set from django.conf import settings from django.core.management.base import BaseCommand from django.core.management.base import CommandError +from watchdog.events import FileSystemEventHandler +from watchdog.observers.polling import PollingObserver + from documents.data_models import ConsumableDocument from documents.data_models import DocumentMetadataOverrides from documents.data_models import DocumentSource from documents.models import Tag from documents.parsers import is_file_ext_supported from documents.tasks import consume_file -from watchdog.events import FileSystemEventHandler -from watchdog.observers.polling import PollingObserver try: - from inotifyrecursive import INotify, flags + from inotifyrecursive import INotify + from inotifyrecursive import flags except ImportError: # pragma: nocover INotify = flags = None diff --git a/src/documents/management/commands/document_exporter.py b/src/documents/management/commands/document_exporter.py index 151868137..7364e7295 100644 --- a/src/documents/management/commands/document_exporter.py +++ b/src/documents/management/commands/document_exporter.py @@ -17,6 +17,10 @@ from django.core.management.base import BaseCommand from django.core.management.base import CommandError from django.db import transaction from django.utils import timezone +from filelock import FileLock + +from documents.file_handling import delete_empty_directories +from documents.file_handling import generate_filename from documents.models import Correspondent from documents.models import Document from documents.models import DocumentType @@ -29,15 +33,11 @@ from documents.models import UiSettings from documents.settings import EXPORTER_ARCHIVE_NAME from documents.settings import EXPORTER_FILE_NAME from documents.settings import EXPORTER_THUMBNAIL_NAME -from filelock import FileLock from paperless import version from paperless.db import GnuPG from paperless_mail.models import MailAccount from paperless_mail.models import MailRule -from documents.file_handling import delete_empty_directories -from documents.file_handling import generate_filename - class Command(BaseCommand): diff --git a/src/documents/management/commands/document_importer.py b/src/documents/management/commands/document_importer.py index 0676117e7..dd294d463 100644 --- a/src/documents/management/commands/document_importer.py +++ b/src/documents/management/commands/document_importer.py @@ -14,16 +14,16 @@ from django.core.management.base import CommandError from django.core.serializers.base import DeserializationError from django.db.models.signals import m2m_changed from django.db.models.signals import post_save +from filelock import FileLock + +from documents.file_handling import create_source_path_directory from documents.models import Document from documents.parsers import run_convert from documents.settings import EXPORTER_ARCHIVE_NAME from documents.settings import EXPORTER_FILE_NAME from documents.settings import EXPORTER_THUMBNAIL_NAME -from filelock import FileLock -from paperless import version - -from documents.file_handling import create_source_path_directory from documents.signals.handlers import update_filename_and_move_files +from paperless import version @contextmanager diff --git a/src/documents/management/commands/document_index.py b/src/documents/management/commands/document_index.py index cf7eb65e5..77a24fa17 100644 --- a/src/documents/management/commands/document_index.py +++ b/src/documents/management/commands/document_index.py @@ -1,5 +1,6 @@ from django.core.management import BaseCommand from django.db import transaction + from documents.tasks import index_optimize from documents.tasks import index_reindex diff --git a/src/documents/management/commands/document_renamer.py b/src/documents/management/commands/document_renamer.py index 79c46f905..028754af1 100644 --- a/src/documents/management/commands/document_renamer.py +++ b/src/documents/management/commands/document_renamer.py @@ -3,6 +3,7 @@ import logging import tqdm from django.core.management.base import BaseCommand from django.db.models.signals import post_save + from documents.models import Document diff --git a/src/documents/management/commands/document_retagger.py b/src/documents/management/commands/document_retagger.py index aa61f0696..a59b1debc 100644 --- a/src/documents/management/commands/document_retagger.py +++ b/src/documents/management/commands/document_retagger.py @@ -2,15 +2,14 @@ import logging import tqdm from django.core.management.base import BaseCommand + from documents.classifier import load_classifier from documents.models import Document - from documents.signals.handlers import set_correspondent from documents.signals.handlers import set_document_type from documents.signals.handlers import set_storage_path from documents.signals.handlers import set_tags - logger = logging.getLogger("paperless.management.retagger") diff --git a/src/documents/management/commands/document_sanity_checker.py b/src/documents/management/commands/document_sanity_checker.py index 27c119863..86b62a4d9 100644 --- a/src/documents/management/commands/document_sanity_checker.py +++ b/src/documents/management/commands/document_sanity_checker.py @@ -1,4 +1,5 @@ from django.core.management.base import BaseCommand + from documents.sanity_checker import check_sanity diff --git a/src/documents/management/commands/document_thumbnails.py b/src/documents/management/commands/document_thumbnails.py index 462853f84..fb308ac04 100644 --- a/src/documents/management/commands/document_thumbnails.py +++ b/src/documents/management/commands/document_thumbnails.py @@ -5,8 +5,8 @@ import shutil import tqdm from django import db from django.core.management.base import BaseCommand -from documents.models import Document +from documents.models import Document from documents.parsers import get_parser_class_for_mime_type diff --git a/src/documents/management/commands/manage_superuser.py b/src/documents/management/commands/manage_superuser.py index 2f506b54a..e85cdfa59 100644 --- a/src/documents/management/commands/manage_superuser.py +++ b/src/documents/management/commands/manage_superuser.py @@ -4,7 +4,6 @@ import os from django.contrib.auth.models import User from django.core.management.base import BaseCommand - logger = logging.getLogger("paperless.management.superuser") diff --git a/src/documents/matching.py b/src/documents/matching.py index ad80ee0ad..39a3d52b5 100644 --- a/src/documents/matching.py +++ b/src/documents/matching.py @@ -8,7 +8,6 @@ from documents.models import StoragePath from documents.models import Tag from documents.permissions import get_objects_for_user_owner_aware - logger = logging.getLogger("paperless.matching") diff --git a/src/documents/migrations/0001_initial.py b/src/documents/migrations/0001_initial.py index e1b2f2a8b..aa8318d6b 100644 --- a/src/documents/migrations/0001_initial.py +++ b/src/documents/migrations/0001_initial.py @@ -1,7 +1,8 @@ # Generated by Django 1.9 on 2015-12-20 19:10 -from django.db import migrations, models from django.conf import settings +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/0002_auto_20151226_1316.py b/src/documents/migrations/0002_auto_20151226_1316.py index b953d8008..c1cd11a42 100644 --- a/src/documents/migrations/0002_auto_20151226_1316.py +++ b/src/documents/migrations/0002_auto_20151226_1316.py @@ -1,7 +1,8 @@ # Generated by Django 1.9 on 2015-12-26 13:16 -from django.db import migrations, models import django.utils.timezone +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/0003_sender.py b/src/documents/migrations/0003_sender.py index c2b274085..dacba5505 100644 --- a/src/documents/migrations/0003_sender.py +++ b/src/documents/migrations/0003_sender.py @@ -1,10 +1,9 @@ # Generated by Django 1.9 on 2016-01-11 12:21 -from django.db import migrations, models -from django.template.defaultfilters import slugify - import django.db.models.deletion - +from django.db import migrations +from django.db import models +from django.template.defaultfilters import slugify DOCUMENT_SENDER_MAP = {} diff --git a/src/documents/migrations/0004_auto_20160114_1844.py b/src/documents/migrations/0004_auto_20160114_1844.py index b3ccaaa9b..e6068c616 100644 --- a/src/documents/migrations/0004_auto_20160114_1844.py +++ b/src/documents/migrations/0004_auto_20160114_1844.py @@ -1,7 +1,8 @@ # Generated by Django 1.9 on 2016-01-14 18:44 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/0006_auto_20160123_0430.py b/src/documents/migrations/0006_auto_20160123_0430.py index 3f24992e2..04142c77a 100644 --- a/src/documents/migrations/0006_auto_20160123_0430.py +++ b/src/documents/migrations/0006_auto_20160123_0430.py @@ -1,6 +1,7 @@ # Generated by Django 1.9 on 2016-01-23 04:30 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/0007_auto_20160126_2114.py b/src/documents/migrations/0007_auto_20160126_2114.py index f4b3b913d..0bc568fb5 100644 --- a/src/documents/migrations/0007_auto_20160126_2114.py +++ b/src/documents/migrations/0007_auto_20160126_2114.py @@ -1,6 +1,7 @@ # Generated by Django 1.9 on 2016-01-26 21:14 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/0008_document_file_type.py b/src/documents/migrations/0008_document_file_type.py index c079f927d..ae085d463 100644 --- a/src/documents/migrations/0008_document_file_type.py +++ b/src/documents/migrations/0008_document_file_type.py @@ -1,6 +1,7 @@ # Generated by Django 1.9 on 2016-01-29 22:58 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/0009_auto_20160214_0040.py b/src/documents/migrations/0009_auto_20160214_0040.py index 82e48ba24..3b8d4e4b7 100644 --- a/src/documents/migrations/0009_auto_20160214_0040.py +++ b/src/documents/migrations/0009_auto_20160214_0040.py @@ -1,6 +1,7 @@ # Generated by Django 1.9 on 2016-02-14 00:40 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/0010_log.py b/src/documents/migrations/0010_log.py index 9be7b18ed..0cc34b4db 100644 --- a/src/documents/migrations/0010_log.py +++ b/src/documents/migrations/0010_log.py @@ -1,6 +1,7 @@ # Generated by Django 1.9 on 2016-02-27 17:54 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/0012_auto_20160305_0040.py b/src/documents/migrations/0012_auto_20160305_0040.py index 1470ace96..e23235d41 100644 --- a/src/documents/migrations/0012_auto_20160305_0040.py +++ b/src/documents/migrations/0012_auto_20160305_0040.py @@ -1,12 +1,12 @@ # Generated by Django 1.9.2 on 2016-03-05 00:40 -import gnupg import os import re import shutil import subprocess import tempfile +import gnupg from django.conf import settings from django.db import migrations from django.utils.termcolors import colorize as colourise # Spelling hurts me diff --git a/src/documents/migrations/0013_auto_20160325_2111.py b/src/documents/migrations/0013_auto_20160325_2111.py index 6663edad8..07bb50873 100644 --- a/src/documents/migrations/0013_auto_20160325_2111.py +++ b/src/documents/migrations/0013_auto_20160325_2111.py @@ -1,7 +1,8 @@ # Generated by Django 1.9.4 on 2016-03-25 21:11 -from django.db import migrations, models import django.utils.timezone +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/0014_document_checksum.py b/src/documents/migrations/0014_document_checksum.py index a687e43ef..985167701 100644 --- a/src/documents/migrations/0014_document_checksum.py +++ b/src/documents/migrations/0014_document_checksum.py @@ -1,12 +1,13 @@ # Generated by Django 1.9.4 on 2016-03-28 19:09 -import gnupg import hashlib import os import django.utils.timezone +import gnupg from django.conf import settings -from django.db import migrations, models +from django.db import migrations +from django.db import models from django.template.defaultfilters import slugify from django.utils.termcolors import colorize as colourise # Spelling hurts me diff --git a/src/documents/migrations/0015_add_insensitive_to_match.py b/src/documents/migrations/0015_add_insensitive_to_match.py index 796918446..5ea281846 100644 --- a/src/documents/migrations/0015_add_insensitive_to_match.py +++ b/src/documents/migrations/0015_add_insensitive_to_match.py @@ -1,6 +1,7 @@ # Generated by Django 1.10.2 on 2016-10-05 21:38 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/0016_auto_20170325_1558.py b/src/documents/migrations/0016_auto_20170325_1558.py index 26ab3a720..4eb1db4a6 100644 --- a/src/documents/migrations/0016_auto_20170325_1558.py +++ b/src/documents/migrations/0016_auto_20170325_1558.py @@ -1,7 +1,8 @@ # Generated by Django 1.10.5 on 2017-03-25 15:58 -from django.db import migrations, models from django.conf import settings +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/0017_auto_20170512_0507.py b/src/documents/migrations/0017_auto_20170512_0507.py index f775cdfe0..47dede6dc 100644 --- a/src/documents/migrations/0017_auto_20170512_0507.py +++ b/src/documents/migrations/0017_auto_20170512_0507.py @@ -1,6 +1,7 @@ # Generated by Django 1.10.5 on 2017-05-12 05:07 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/0018_auto_20170715_1712.py b/src/documents/migrations/0018_auto_20170715_1712.py index 047531fee..07bd630ab 100644 --- a/src/documents/migrations/0018_auto_20170715_1712.py +++ b/src/documents/migrations/0018_auto_20170715_1712.py @@ -1,7 +1,8 @@ # Generated by Django 1.10.5 on 2017-07-15 17:12 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/0020_document_added.py b/src/documents/migrations/0020_document_added.py index 67c4df4aa..34042eedf 100644 --- a/src/documents/migrations/0020_document_added.py +++ b/src/documents/migrations/0020_document_added.py @@ -1,5 +1,6 @@ -from django.db import migrations, models import django.utils.timezone +from django.db import migrations +from django.db import models def set_added_time_to_created_time(apps, schema_editor): diff --git a/src/documents/migrations/0021_document_storage_type.py b/src/documents/migrations/0021_document_storage_type.py index bde86ceea..b4239d055 100644 --- a/src/documents/migrations/0021_document_storage_type.py +++ b/src/documents/migrations/0021_document_storage_type.py @@ -1,6 +1,7 @@ # Generated by Django 1.11.10 on 2018-02-04 13:07 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/0022_auto_20181007_1420.py b/src/documents/migrations/0022_auto_20181007_1420.py index ecebf80d8..446f03c92 100644 --- a/src/documents/migrations/0022_auto_20181007_1420.py +++ b/src/documents/migrations/0022_auto_20181007_1420.py @@ -1,6 +1,7 @@ # Generated by Django 2.0.8 on 2018-10-07 14:20 -from django.db import migrations, models +from django.db import migrations +from django.db import models from django.utils.text import slugify diff --git a/src/documents/migrations/0023_document_current_filename.py b/src/documents/migrations/0023_document_current_filename.py index 65300c11e..3c5ebbef1 100644 --- a/src/documents/migrations/0023_document_current_filename.py +++ b/src/documents/migrations/0023_document_current_filename.py @@ -1,6 +1,7 @@ # Generated by Django 2.0.10 on 2019-04-26 18:57 -from django.db import migrations, models +from django.db import migrations +from django.db import models def set_filename(apps, schema_editor): diff --git a/src/documents/migrations/1000_update_paperless_all.py b/src/documents/migrations/1000_update_paperless_all.py index 4301a5b21..294731c51 100644 --- a/src/documents/migrations/1000_update_paperless_all.py +++ b/src/documents/migrations/1000_update_paperless_all.py @@ -1,8 +1,9 @@ # Generated by Django 3.1.3 on 2020-11-07 12:35 import uuid -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations +from django.db import models def logs_set_default_group(apps, schema_editor): diff --git a/src/documents/migrations/1002_auto_20201111_1105.py b/src/documents/migrations/1002_auto_20201111_1105.py index f502fba3f..d58f3bfe6 100644 --- a/src/documents/migrations/1002_auto_20201111_1105.py +++ b/src/documents/migrations/1002_auto_20201111_1105.py @@ -1,6 +1,7 @@ # Generated by Django 3.1.3 on 2020-11-11 11:05 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1003_mime_types.py b/src/documents/migrations/1003_mime_types.py index f5ac94756..0d5f259c7 100644 --- a/src/documents/migrations/1003_mime_types.py +++ b/src/documents/migrations/1003_mime_types.py @@ -3,7 +3,8 @@ import os import magic from django.conf import settings -from django.db import migrations, models +from django.db import migrations +from django.db import models from paperless.db import GnuPG diff --git a/src/documents/migrations/1005_checksums.py b/src/documents/migrations/1005_checksums.py index b1bfc6eac..cbbd928aa 100644 --- a/src/documents/migrations/1005_checksums.py +++ b/src/documents/migrations/1005_checksums.py @@ -1,6 +1,7 @@ # Generated by Django 3.1.3 on 2020-11-29 00:48 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1007_savedview_savedviewfilterrule.py b/src/documents/migrations/1007_savedview_savedviewfilterrule.py index 357d65c2d..b145b7be5 100644 --- a/src/documents/migrations/1007_savedview_savedviewfilterrule.py +++ b/src/documents/migrations/1007_savedview_savedviewfilterrule.py @@ -1,8 +1,9 @@ # Generated by Django 3.1.4 on 2020-12-12 14:41 -from django.conf import settings -from django.db import migrations, models import django.db.models.deletion +from django.conf import settings +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1008_auto_20201216_1736.py b/src/documents/migrations/1008_auto_20201216_1736.py index 2f6c5c59d..6539bdfc1 100644 --- a/src/documents/migrations/1008_auto_20201216_1736.py +++ b/src/documents/migrations/1008_auto_20201216_1736.py @@ -1,7 +1,7 @@ # Generated by Django 3.1.4 on 2020-12-16 17:36 -from django.db import migrations import django.db.models.functions.text +from django.db import migrations class Migration(migrations.Migration): diff --git a/src/documents/migrations/1010_auto_20210101_2159.py b/src/documents/migrations/1010_auto_20210101_2159.py index 1d05d8f47..ea679ace6 100644 --- a/src/documents/migrations/1010_auto_20210101_2159.py +++ b/src/documents/migrations/1010_auto_20210101_2159.py @@ -1,6 +1,7 @@ # Generated by Django 3.1.4 on 2021-01-01 21:59 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1011_auto_20210101_2340.py b/src/documents/migrations/1011_auto_20210101_2340.py index c7c387226..b26ace662 100644 --- a/src/documents/migrations/1011_auto_20210101_2340.py +++ b/src/documents/migrations/1011_auto_20210101_2340.py @@ -1,9 +1,10 @@ # Generated by Django 3.1.4 on 2021-01-01 23:40 -from django.conf import settings -from django.db import migrations, models import django.db.models.deletion import django.utils.timezone +from django.conf import settings +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1012_fix_archive_files.py b/src/documents/migrations/1012_fix_archive_files.py index 51eb8ec2e..b076f1ca9 100644 --- a/src/documents/migrations/1012_fix_archive_files.py +++ b/src/documents/migrations/1012_fix_archive_files.py @@ -8,11 +8,12 @@ from time import sleep import pathvalidate from django.conf import settings -from django.db import migrations, models +from django.db import migrations +from django.db import models from django.template.defaultfilters import slugify -from documents.file_handling import defaultdictNoStr, many_to_dictionary - +from documents.file_handling import defaultdictNoStr +from documents.file_handling import many_to_dictionary logger = logging.getLogger("paperless.migrations") @@ -160,11 +161,9 @@ def parse_wrapper(parser, path, mime_type, file_name): def create_archive_version(doc, retry_count=3): - from documents.parsers import ( - get_parser_class_for_mime_type, - DocumentParser, - ParseError, - ) + from documents.parsers import DocumentParser + from documents.parsers import ParseError + from documents.parsers import get_parser_class_for_mime_type logger.info(f"Regenerating archive document for document ID:{doc.id}") parser_class = get_parser_class_for_mime_type(doc.mime_type) diff --git a/src/documents/migrations/1013_migrate_tag_colour.py b/src/documents/migrations/1013_migrate_tag_colour.py index 8346ff184..07d29e155 100644 --- a/src/documents/migrations/1013_migrate_tag_colour.py +++ b/src/documents/migrations/1013_migrate_tag_colour.py @@ -1,6 +1,7 @@ # Generated by Django 3.1.4 on 2020-12-02 21:43 -from django.db import migrations, models +from django.db import migrations +from django.db import models COLOURS_OLD = { 1: "#a6cee3", diff --git a/src/documents/migrations/1014_auto_20210228_1614.py b/src/documents/migrations/1014_auto_20210228_1614.py index c3f16b841..821d8c028 100644 --- a/src/documents/migrations/1014_auto_20210228_1614.py +++ b/src/documents/migrations/1014_auto_20210228_1614.py @@ -1,6 +1,7 @@ # Generated by Django 3.1.7 on 2021-02-28 15:14 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1015_remove_null_characters.py b/src/documents/migrations/1015_remove_null_characters.py index cea9d5a64..304c5c28a 100644 --- a/src/documents/migrations/1015_remove_null_characters.py +++ b/src/documents/migrations/1015_remove_null_characters.py @@ -3,7 +3,6 @@ import logging from django.db import migrations - logger = logging.getLogger("paperless.migrations") diff --git a/src/documents/migrations/1016_auto_20210317_1351.py b/src/documents/migrations/1016_auto_20210317_1351.py index d41fae849..36892a97a 100644 --- a/src/documents/migrations/1016_auto_20210317_1351.py +++ b/src/documents/migrations/1016_auto_20210317_1351.py @@ -1,6 +1,7 @@ # Generated by Django 3.1.7 on 2021-03-17 12:51 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1017_alter_savedviewfilterrule_rule_type.py b/src/documents/migrations/1017_alter_savedviewfilterrule_rule_type.py index 52db95138..827924767 100644 --- a/src/documents/migrations/1017_alter_savedviewfilterrule_rule_type.py +++ b/src/documents/migrations/1017_alter_savedviewfilterrule_rule_type.py @@ -1,6 +1,7 @@ # Generated by Django 3.2.12 on 2022-03-17 11:59 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1018_alter_savedviewfilterrule_value.py b/src/documents/migrations/1018_alter_savedviewfilterrule_value.py index 8453a86d8..d734e520e 100644 --- a/src/documents/migrations/1018_alter_savedviewfilterrule_value.py +++ b/src/documents/migrations/1018_alter_savedviewfilterrule_value.py @@ -1,6 +1,7 @@ # Generated by Django 4.0.3 on 2022-04-01 22:50 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1019_storagepath_document_storage_path.py b/src/documents/migrations/1019_storagepath_document_storage_path.py index ff7f38692..f25162f2a 100644 --- a/src/documents/migrations/1019_storagepath_document_storage_path.py +++ b/src/documents/migrations/1019_storagepath_document_storage_path.py @@ -1,7 +1,8 @@ # Generated by Django 4.0.4 on 2022-05-02 15:56 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1019_uisettings.py b/src/documents/migrations/1019_uisettings.py index edc944a37..5ca826f06 100644 --- a/src/documents/migrations/1019_uisettings.py +++ b/src/documents/migrations/1019_uisettings.py @@ -1,8 +1,9 @@ # Generated by Django 4.0.4 on 2022-05-07 05:10 -from django.conf import settings -from django.db import migrations, models import django.db.models.deletion +from django.conf import settings +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1021_webp_thumbnail_conversion.py b/src/documents/migrations/1021_webp_thumbnail_conversion.py index c7ae1eaae..336a7fde5 100644 --- a/src/documents/migrations/1021_webp_thumbnail_conversion.py +++ b/src/documents/migrations/1021_webp_thumbnail_conversion.py @@ -8,6 +8,7 @@ from pathlib import Path from django.conf import settings from django.db import migrations + from documents.parsers import run_convert logger = logging.getLogger("paperless.migrations") diff --git a/src/documents/migrations/1022_paperlesstask.py b/src/documents/migrations/1022_paperlesstask.py index e398402f3..dfbd429c4 100644 --- a/src/documents/migrations/1022_paperlesstask.py +++ b/src/documents/migrations/1022_paperlesstask.py @@ -1,7 +1,8 @@ # Generated by Django 4.0.4 on 2022-05-23 07:14 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1023_add_comments.py b/src/documents/migrations/1023_add_comments.py index 2c89947e9..0b26739bc 100644 --- a/src/documents/migrations/1023_add_comments.py +++ b/src/documents/migrations/1023_add_comments.py @@ -1,6 +1,7 @@ -from django.db import migrations, models import django.utils.timezone from django.conf import settings +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1024_document_original_filename.py b/src/documents/migrations/1024_document_original_filename.py index b0f03cd50..31414cf8d 100644 --- a/src/documents/migrations/1024_document_original_filename.py +++ b/src/documents/migrations/1024_document_original_filename.py @@ -1,6 +1,7 @@ # Generated by Django 4.0.6 on 2022-07-25 06:34 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1025_alter_savedviewfilterrule_rule_type.py b/src/documents/migrations/1025_alter_savedviewfilterrule_rule_type.py index 1e5b005b8..0c0492586 100644 --- a/src/documents/migrations/1025_alter_savedviewfilterrule_rule_type.py +++ b/src/documents/migrations/1025_alter_savedviewfilterrule_rule_type.py @@ -1,6 +1,7 @@ # Generated by Django 4.0.5 on 2022-08-26 16:49 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1026_transition_to_celery.py b/src/documents/migrations/1026_transition_to_celery.py index 786ca36c4..3920204a9 100644 --- a/src/documents/migrations/1026_transition_to_celery.py +++ b/src/documents/migrations/1026_transition_to_celery.py @@ -1,7 +1,8 @@ # Generated by Django 4.1.1 on 2022-09-27 19:31 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1027_remove_paperlesstask_attempted_task_and_more.py b/src/documents/migrations/1027_remove_paperlesstask_attempted_task_and_more.py index fc8ff8ec2..2d39e6451 100644 --- a/src/documents/migrations/1027_remove_paperlesstask_attempted_task_and_more.py +++ b/src/documents/migrations/1027_remove_paperlesstask_attempted_task_and_more.py @@ -1,7 +1,8 @@ # Generated by Django 4.1.2 on 2022-10-17 16:31 -from django.db import migrations, models import django.utils.timezone +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1029_alter_document_archive_serial_number.py b/src/documents/migrations/1029_alter_document_archive_serial_number.py index d7e4b662d..69a74fc2d 100644 --- a/src/documents/migrations/1029_alter_document_archive_serial_number.py +++ b/src/documents/migrations/1029_alter_document_archive_serial_number.py @@ -1,7 +1,8 @@ # Generated by Django 4.1.4 on 2023-01-24 17:56 import django.core.validators -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1030_alter_paperlesstask_task_file_name.py b/src/documents/migrations/1030_alter_paperlesstask_task_file_name.py index 130358bec..93569ae83 100644 --- a/src/documents/migrations/1030_alter_paperlesstask_task_file_name.py +++ b/src/documents/migrations/1030_alter_paperlesstask_task_file_name.py @@ -1,6 +1,7 @@ # Generated by Django 4.1.5 on 2023-02-03 21:53 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1031_remove_savedview_user_correspondent_owner_and_more.py b/src/documents/migrations/1031_remove_savedview_user_correspondent_owner_and_more.py index b187871e7..d29bdf6e6 100644 --- a/src/documents/migrations/1031_remove_savedview_user_correspondent_owner_and_more.py +++ b/src/documents/migrations/1031_remove_savedview_user_correspondent_owner_and_more.py @@ -1,8 +1,9 @@ # Generated by Django 4.1.4 on 2022-02-03 04:24 -from django.conf import settings -from django.db import migrations, models import django.db.models.deletion +from django.conf import settings +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1032_alter_correspondent_matching_algorithm_and_more.py b/src/documents/migrations/1032_alter_correspondent_matching_algorithm_and_more.py index 88aa7f2bc..2e83338ab 100644 --- a/src/documents/migrations/1032_alter_correspondent_matching_algorithm_and_more.py +++ b/src/documents/migrations/1032_alter_correspondent_matching_algorithm_and_more.py @@ -1,6 +1,7 @@ # Generated by Django 4.1.7 on 2023-02-22 00:45 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1033_alter_documenttype_options_alter_tag_options_and_more.py b/src/documents/migrations/1033_alter_documenttype_options_alter_tag_options_and_more.py index 433363e9f..1d1a3227d 100644 --- a/src/documents/migrations/1033_alter_documenttype_options_alter_tag_options_and_more.py +++ b/src/documents/migrations/1033_alter_documenttype_options_alter_tag_options_and_more.py @@ -1,6 +1,7 @@ # Generated by Django 4.1.5 on 2023-03-04 22:33 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1034_alter_savedviewfilterrule_rule_type.py b/src/documents/migrations/1034_alter_savedviewfilterrule_rule_type.py index aa56d9629..6612edafa 100644 --- a/src/documents/migrations/1034_alter_savedviewfilterrule_rule_type.py +++ b/src/documents/migrations/1034_alter_savedviewfilterrule_rule_type.py @@ -1,6 +1,7 @@ # Generated by Django 4.1.5 on 2023-03-15 07:10 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/documents/migrations/1035_rename_comment_note.py b/src/documents/migrations/1035_rename_comment_note.py index 11c3da380..a87e285ac 100644 --- a/src/documents/migrations/1035_rename_comment_note.py +++ b/src/documents/migrations/1035_rename_comment_note.py @@ -1,9 +1,9 @@ # Generated by Django 4.1.5 on 2023-03-17 22:15 +import django.db.models.deletion from django.conf import settings from django.db import migrations from django.db import models -import django.db.models.deletion class Migration(migrations.Migration): diff --git a/src/documents/models.py b/src/documents/models.py index 079459d00..bdcd080fd 100644 --- a/src/documents/models.py +++ b/src/documents/models.py @@ -17,6 +17,7 @@ from django.core.validators import MinValueValidator from django.db import models from django.utils import timezone from django.utils.translation import gettext_lazy as _ + from documents.parsers import get_default_file_extension ALL_STATES = sorted(states.ALL_STATES) diff --git a/src/documents/parsers.py b/src/documents/parsers.py index 4bec79c61..1c5c5ebb0 100644 --- a/src/documents/parsers.py +++ b/src/documents/parsers.py @@ -14,6 +14,7 @@ from typing import Set from django.conf import settings from django.utils import timezone + from documents.loggers import LoggingMixin from documents.signals import document_consumer_declaration diff --git a/src/documents/sanity_checker.py b/src/documents/sanity_checker.py index b74d07bd5..7b4107e99 100644 --- a/src/documents/sanity_checker.py +++ b/src/documents/sanity_checker.py @@ -5,9 +5,10 @@ from pathlib import Path from typing import Final from django.conf import settings -from documents.models import Document from tqdm import tqdm +from documents.models import Document + class SanityCheckMessages: def __init__(self): diff --git a/src/documents/serialisers.py b/src/documents/serialisers.py index 2ad392f4c..1727fb135 100644 --- a/src/documents/serialisers.py +++ b/src/documents/serialisers.py @@ -10,32 +10,30 @@ except ImportError: from backports import zoneinfo import magic from django.conf import settings +from django.contrib.auth.models import Group +from django.contrib.auth.models import User from django.utils.text import slugify from django.utils.translation import gettext as _ +from guardian.shortcuts import get_users_with_perms from rest_framework import serializers from rest_framework.fields import SerializerMethodField +from documents.permissions import get_groups_with_only_permission +from documents.permissions import set_permissions_for_object + from . import bulk_edit from .models import Correspondent from .models import Document from .models import DocumentType from .models import MatchingModel +from .models import PaperlessTask from .models import SavedView from .models import SavedViewFilterRule from .models import StoragePath from .models import Tag from .models import UiSettings -from .models import PaperlessTask from .parsers import is_mime_type_supported -from guardian.shortcuts import get_users_with_perms - -from django.contrib.auth.models import User -from django.contrib.auth.models import Group - -from documents.permissions import get_groups_with_only_permission -from documents.permissions import set_permissions_for_object - # https://www.django-rest-framework.org/api-guide/serializers/#example class DynamicFieldsModelSerializer(serializers.ModelSerializer): diff --git a/src/documents/tasks.py b/src/documents/tasks.py index c2d726405..6b19c067b 100644 --- a/src/documents/tasks.py +++ b/src/documents/tasks.py @@ -12,6 +12,10 @@ from channels.layers import get_channel_layer from django.conf import settings from django.db import transaction from django.db.models.signals import post_save +from filelock import FileLock +from redis.exceptions import ConnectionError +from whoosh.writing import AsyncWriter + from documents import barcodes from documents import index from documents import sanity_checker @@ -32,10 +36,6 @@ from documents.models import Tag from documents.parsers import DocumentParser from documents.parsers import get_parser_class_for_mime_type from documents.sanity_checker import SanityCheckFailedException -from filelock import FileLock -from redis.exceptions import ConnectionError -from whoosh.writing import AsyncWriter - logger = logging.getLogger("paperless.tasks") diff --git a/src/documents/tests/test_admin.py b/src/documents/tests/test_admin.py index 7a39c95be..a32a31adf 100644 --- a/src/documents/tests/test_admin.py +++ b/src/documents/tests/test_admin.py @@ -1,6 +1,7 @@ from django.contrib.admin.sites import AdminSite from django.test import TestCase from django.utils import timezone + from documents import index from documents.admin import DocumentAdmin from documents.models import Document diff --git a/src/documents/tests/test_api.py b/src/documents/tests/test_api.py index ba5c58f3f..a855a0488 100644 --- a/src/documents/tests/test_api.py +++ b/src/documents/tests/test_api.py @@ -20,30 +20,31 @@ except ImportError: from backports import zoneinfo import pytest +from dateutil.relativedelta import relativedelta from django.conf import settings from django.contrib.auth.models import Group from django.contrib.auth.models import Permission from django.contrib.auth.models import User from django.test import override_settings from django.utils import timezone -from dateutil.relativedelta import relativedelta from rest_framework import status +from rest_framework.test import APITestCase +from whoosh.writing import AsyncWriter + from documents import bulk_edit from documents import index from documents.models import Correspondent from documents.models import Document -from documents.tests.utils import DocumentConsumeDelayMixin from documents.models import DocumentType from documents.models import MatchingModel +from documents.models import Note from documents.models import PaperlessTask from documents.models import SavedView from documents.models import StoragePath from documents.models import Tag -from documents.models import Note from documents.tests.utils import DirectoriesMixin +from documents.tests.utils import DocumentConsumeDelayMixin from paperless import version -from rest_framework.test import APITestCase -from whoosh.writing import AsyncWriter class TestDocumentApi(DirectoriesMixin, DocumentConsumeDelayMixin, APITestCase): diff --git a/src/documents/tests/test_barcodes.py b/src/documents/tests/test_barcodes.py index 2520c7df6..5a6c3edf9 100644 --- a/src/documents/tests/test_barcodes.py +++ b/src/documents/tests/test_barcodes.py @@ -4,8 +4,10 @@ from unittest import mock import pytest from django.conf import settings -from django.test import override_settings from django.test import TestCase +from django.test import override_settings +from PIL import Image + from documents import barcodes from documents import tasks from documents.consumer import ConsumerError @@ -13,7 +15,6 @@ from documents.data_models import ConsumableDocument from documents.data_models import DocumentSource from documents.tests.utils import DirectoriesMixin from documents.tests.utils import FileSystemAssertsMixin -from PIL import Image try: import zxingcpp # noqa: F401 diff --git a/src/documents/tests/test_checks.py b/src/documents/tests/test_checks.py index a331572da..0f645c56d 100644 --- a/src/documents/tests/test_checks.py +++ b/src/documents/tests/test_checks.py @@ -2,8 +2,9 @@ import textwrap from unittest import mock from django.core.checks import Error -from django.test import override_settings from django.test import TestCase +from django.test import override_settings + from documents.checks import changed_password_check from documents.checks import parser_check from documents.models import Document diff --git a/src/documents/tests/test_classifier.py b/src/documents/tests/test_classifier.py index f0aa5894e..68e054586 100644 --- a/src/documents/tests/test_classifier.py +++ b/src/documents/tests/test_classifier.py @@ -5,8 +5,9 @@ from unittest import mock import pytest from django.conf import settings -from django.test import override_settings from django.test import TestCase +from django.test import override_settings + from documents.classifier import ClassifierModelCorruptError from documents.classifier import DocumentClassifier from documents.classifier import IncompatibleClassifierVersionError diff --git a/src/documents/tests/test_consumer.py b/src/documents/tests/test_consumer.py index cd06e9782..1a7ebd4fe 100644 --- a/src/documents/tests/test_consumer.py +++ b/src/documents/tests/test_consumer.py @@ -15,9 +15,9 @@ except ImportError: from backports import zoneinfo from django.conf import settings -from django.utils import timezone -from django.test import override_settings from django.test import TestCase +from django.test import override_settings +from django.utils import timezone from documents.consumer import Consumer from documents.consumer import ConsumerError @@ -29,9 +29,10 @@ from documents.models import Tag from documents.parsers import DocumentParser from documents.parsers import ParseError from documents.tasks import sanity_check -from .utils import DirectoriesMixin from documents.tests.utils import FileSystemAssertsMixin +from .utils import DirectoriesMixin + class TestAttributes(TestCase): diff --git a/src/documents/tests/test_date_parsing.py b/src/documents/tests/test_date_parsing.py index e1b179976..fd6556365 100644 --- a/src/documents/tests/test_date_parsing.py +++ b/src/documents/tests/test_date_parsing.py @@ -5,8 +5,9 @@ from uuid import uuid4 from dateutil import tz from django.conf import settings -from django.test import override_settings from django.test import TestCase +from django.test import override_settings + from documents.parsers import parse_date from documents.parsers import parse_date_generator diff --git a/src/documents/tests/test_document_model.py b/src/documents/tests/test_document_model.py index 763f5049c..6168503dc 100644 --- a/src/documents/tests/test_document_model.py +++ b/src/documents/tests/test_document_model.py @@ -8,8 +8,8 @@ try: except ImportError: from backports import zoneinfo -from django.test import override_settings from django.test import TestCase +from django.test import override_settings from django.utils import timezone from documents.models import Correspondent diff --git a/src/documents/tests/test_file_handling.py b/src/documents/tests/test_file_handling.py index d2f61eb1c..7dea33925 100644 --- a/src/documents/tests/test_file_handling.py +++ b/src/documents/tests/test_file_handling.py @@ -7,8 +7,8 @@ from unittest import mock from django.conf import settings from django.contrib.auth.models import User from django.db import DatabaseError -from django.test import override_settings from django.test import TestCase +from django.test import override_settings from django.utils import timezone from documents.file_handling import create_source_path_directory diff --git a/src/documents/tests/test_importer.py b/src/documents/tests/test_importer.py index a98e7394b..212769eda 100644 --- a/src/documents/tests/test_importer.py +++ b/src/documents/tests/test_importer.py @@ -1,12 +1,13 @@ +import tempfile +from pathlib import Path + +from django.core.management import call_command from django.core.management.base import CommandError from django.test import TestCase -from documents.settings import EXPORTER_FILE_NAME -from documents.settings import EXPORTER_ARCHIVE_NAME -from pathlib import Path -import tempfile -from django.core.management import call_command from documents.management.commands.document_importer import Command +from documents.settings import EXPORTER_ARCHIVE_NAME +from documents.settings import EXPORTER_FILE_NAME class TestImporter(TestCase): diff --git a/src/documents/tests/test_index.py b/src/documents/tests/test_index.py index bf1865a43..bae56ab77 100644 --- a/src/documents/tests/test_index.py +++ b/src/documents/tests/test_index.py @@ -1,6 +1,7 @@ from unittest import mock from django.test import TestCase + from documents import index from documents.models import Document from documents.tests.utils import DirectoriesMixin diff --git a/src/documents/tests/test_management.py b/src/documents/tests/test_management.py index d5b81a5e1..2ea54d63c 100644 --- a/src/documents/tests/test_management.py +++ b/src/documents/tests/test_management.py @@ -7,15 +7,15 @@ from pathlib import Path from unittest import mock from django.core.management import call_command -from django.test import override_settings from django.test import TestCase +from django.test import override_settings + from documents.file_handling import generate_filename from documents.models import Document from documents.tasks import update_document_archive_file from documents.tests.utils import DirectoriesMixin from documents.tests.utils import FileSystemAssertsMixin - sample_file = os.path.join(os.path.dirname(__file__), "samples", "simple.pdf") diff --git a/src/documents/tests/test_management_consumer.py b/src/documents/tests/test_management_consumer.py index 1230288c5..067702766 100644 --- a/src/documents/tests/test_management_consumer.py +++ b/src/documents/tests/test_management_consumer.py @@ -7,10 +7,11 @@ from time import sleep from unittest import mock from django.conf import settings -from django.core.management import call_command from django.core.management import CommandError -from django.test import override_settings +from django.core.management import call_command from django.test import TransactionTestCase +from django.test import override_settings + from documents.consumer import ConsumerError from documents.data_models import ConsumableDocument from documents.management.commands import document_consumer diff --git a/src/documents/tests/test_management_exporter.py b/src/documents/tests/test_management_exporter.py index cc52dc9c1..47f07809e 100644 --- a/src/documents/tests/test_management_exporter.py +++ b/src/documents/tests/test_management_exporter.py @@ -9,9 +9,10 @@ from zipfile import ZipFile from django.core.management import call_command from django.core.management.base import CommandError -from django.test import override_settings from django.test import TestCase +from django.test import override_settings from django.utils import timezone + from documents.management.commands import document_exporter from documents.models import Correspondent from documents.models import Document diff --git a/src/documents/tests/test_management_retagger.py b/src/documents/tests/test_management_retagger.py index 2b7aae649..afbed9d60 100644 --- a/src/documents/tests/test_management_retagger.py +++ b/src/documents/tests/test_management_retagger.py @@ -1,5 +1,6 @@ from django.core.management import call_command from django.test import TestCase + from documents.models import Correspondent from documents.models import Document from documents.models import DocumentType diff --git a/src/documents/tests/test_management_superuser.py b/src/documents/tests/test_management_superuser.py index b79a9f9a6..01f03c8e1 100644 --- a/src/documents/tests/test_management_superuser.py +++ b/src/documents/tests/test_management_superuser.py @@ -5,6 +5,7 @@ from unittest import mock from django.contrib.auth.models import User from django.core.management import call_command from django.test import TestCase + from documents.tests.utils import DirectoriesMixin diff --git a/src/documents/tests/test_management_thumbnails.py b/src/documents/tests/test_management_thumbnails.py index 0767e4e37..6e4e18ea3 100644 --- a/src/documents/tests/test_management_thumbnails.py +++ b/src/documents/tests/test_management_thumbnails.py @@ -4,6 +4,7 @@ from unittest import mock from django.core.management import call_command from django.test import TestCase + from documents.management.commands.document_thumbnails import _process_document from documents.models import Document from documents.tests.utils import DirectoriesMixin diff --git a/src/documents/tests/test_matchables.py b/src/documents/tests/test_matchables.py index 56d47ee46..718ab8696 100644 --- a/src/documents/tests/test_matchables.py +++ b/src/documents/tests/test_matchables.py @@ -5,8 +5,8 @@ from typing import Iterable from django.contrib.admin.models import LogEntry from django.contrib.auth.models import User -from django.test import override_settings from django.test import TestCase +from django.test import override_settings from documents import matching from documents.models import Correspondent diff --git a/src/documents/tests/test_migration_archive_files.py b/src/documents/tests/test_migration_archive_files.py index 32929d92c..8bd191d4d 100644 --- a/src/documents/tests/test_migration_archive_files.py +++ b/src/documents/tests/test_migration_archive_files.py @@ -6,12 +6,12 @@ from unittest import mock from django.conf import settings from django.test import override_settings + from documents.parsers import ParseError from documents.tests.utils import DirectoriesMixin from documents.tests.utils import FileSystemAssertsMixin from documents.tests.utils import TestMigrations - STORAGE_TYPE_GPG = "gpg" diff --git a/src/documents/tests/test_migration_mime_type.py b/src/documents/tests/test_migration_mime_type.py index 7b607a0cf..4dacfb41f 100644 --- a/src/documents/tests/test_migration_mime_type.py +++ b/src/documents/tests/test_migration_mime_type.py @@ -3,6 +3,7 @@ import shutil from django.conf import settings from django.test import override_settings + from documents.parsers import get_default_file_extension from documents.tests.utils import DirectoriesMixin from documents.tests.utils import TestMigrations diff --git a/src/documents/tests/test_migration_webp_conversion.py b/src/documents/tests/test_migration_webp_conversion.py index 9631c5704..d77057114 100644 --- a/src/documents/tests/test_migration_webp_conversion.py +++ b/src/documents/tests/test_migration_webp_conversion.py @@ -7,6 +7,7 @@ from typing import Union from unittest import mock from django.test import override_settings + from documents.tests.utils import TestMigrations diff --git a/src/documents/tests/test_models.py b/src/documents/tests/test_models.py index ee882dd84..70e5061c3 100644 --- a/src/documents/tests/test_models.py +++ b/src/documents/tests/test_models.py @@ -2,6 +2,7 @@ from django.test import TestCase from documents.models import Correspondent from documents.models import Document + from .factories import CorrespondentFactory from .factories import DocumentFactory diff --git a/src/documents/tests/test_parsers.py b/src/documents/tests/test_parsers.py index 7ec06d1a0..fee7234e8 100644 --- a/src/documents/tests/test_parsers.py +++ b/src/documents/tests/test_parsers.py @@ -2,8 +2,9 @@ from tempfile import TemporaryDirectory from unittest import mock from django.apps import apps -from django.test import override_settings from django.test import TestCase +from django.test import override_settings + from documents.parsers import get_default_file_extension from documents.parsers import get_parser_class_for_mime_type from documents.parsers import get_supported_file_extensions diff --git a/src/documents/tests/test_sanity_check.py b/src/documents/tests/test_sanity_check.py index 5fb4adfcc..efee63355 100644 --- a/src/documents/tests/test_sanity_check.py +++ b/src/documents/tests/test_sanity_check.py @@ -6,6 +6,7 @@ from pathlib import Path import filelock from django.conf import settings from django.test import TestCase + from documents.models import Document from documents.sanity_checker import check_sanity from documents.tests.utils import DirectoriesMixin diff --git a/src/documents/tests/test_task_signals.py b/src/documents/tests/test_task_signals.py index d63df0b3c..4a54220e0 100644 --- a/src/documents/tests/test_task_signals.py +++ b/src/documents/tests/test_task_signals.py @@ -3,13 +3,14 @@ from unittest import mock import celery from django.test import TestCase + from documents.data_models import ConsumableDocument from documents.data_models import DocumentSource from documents.models import PaperlessTask from documents.signals.handlers import before_task_publish_handler +from documents.signals.handlers import task_failure_handler from documents.signals.handlers import task_postrun_handler from documents.signals.handlers import task_prerun_handler -from documents.signals.handlers import task_failure_handler from documents.tests.test_consumer import fake_magic_from_file from documents.tests.utils import DirectoriesMixin diff --git a/src/documents/tests/test_tasks.py b/src/documents/tests/test_tasks.py index 2d27f93ec..334345b6a 100644 --- a/src/documents/tests/test_tasks.py +++ b/src/documents/tests/test_tasks.py @@ -4,6 +4,7 @@ from unittest import mock from django.conf import settings from django.test import TestCase from django.utils import timezone + from documents import tasks from documents.models import Correspondent from documents.models import Document diff --git a/src/documents/tests/test_views.py b/src/documents/tests/test_views.py index a8c6a67da..ef62d9adb 100644 --- a/src/documents/tests/test_views.py +++ b/src/documents/tests/test_views.py @@ -3,8 +3,8 @@ import tempfile from django.conf import settings from django.contrib.auth.models import User -from django.test import override_settings from django.test import TestCase +from django.test import override_settings from rest_framework import status diff --git a/src/documents/tests/utils.py b/src/documents/tests/utils.py index 26760f780..72f63e1c5 100644 --- a/src/documents/tests/utils.py +++ b/src/documents/tests/utils.py @@ -12,8 +12,9 @@ from unittest import mock from django.apps import apps from django.db import connection from django.db.migrations.executor import MigrationExecutor -from django.test import override_settings from django.test import TransactionTestCase +from django.test import override_settings + from documents.data_models import ConsumableDocument from documents.data_models import DocumentMetadataOverrides diff --git a/src/paperless/apps.py b/src/paperless/apps.py index 323099745..b4147a2e3 100644 --- a/src/paperless/apps.py +++ b/src/paperless/apps.py @@ -1,5 +1,6 @@ from django.apps import AppConfig from django.utils.translation import gettext_lazy as _ + from paperless.signals import handle_failed_login diff --git a/src/paperless/asgi.py b/src/paperless/asgi.py index 633c75ce0..8d63c347a 100644 --- a/src/paperless/asgi.py +++ b/src/paperless/asgi.py @@ -10,7 +10,8 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "paperless.settings") django_asgi_app = get_asgi_application() from channels.auth import AuthMiddlewareStack # noqa: E402 -from channels.routing import ProtocolTypeRouter, URLRouter # noqa: E402 +from channels.routing import ProtocolTypeRouter # noqa: E402 +from channels.routing import URLRouter # noqa: E402 from paperless.urls import websocket_urlpatterns # noqa: E402 diff --git a/src/paperless/checks.py b/src/paperless/checks.py index b6a931ecc..cda14baad 100644 --- a/src/paperless/checks.py +++ b/src/paperless/checks.py @@ -6,8 +6,8 @@ import stat from django.conf import settings from django.core.checks import Error -from django.core.checks import register from django.core.checks import Warning +from django.core.checks import register exists_message = "{} is set but doesn't exist." exists_hint = "Create a directory at {}" diff --git a/src/paperless/filters.py b/src/paperless/filters.py index 5be7cc2f7..a3c09d50f 100644 --- a/src/paperless/filters.py +++ b/src/paperless/filters.py @@ -1,6 +1,7 @@ from django.contrib.auth.models import Group from django.contrib.auth.models import User from django_filters.rest_framework import FilterSet + from documents.filters import CHAR_KWARGS diff --git a/src/paperless/middleware.py b/src/paperless/middleware.py index ddf12812b..cc54e892d 100644 --- a/src/paperless/middleware.py +++ b/src/paperless/middleware.py @@ -1,4 +1,5 @@ from django.conf import settings + from paperless import version diff --git a/src/paperless/tests/test_checks.py b/src/paperless/tests/test_checks.py index 7c233de23..cd706c532 100644 --- a/src/paperless/tests/test_checks.py +++ b/src/paperless/tests/test_checks.py @@ -1,7 +1,8 @@ import os -from django.test import override_settings from django.test import TestCase +from django.test import override_settings + from documents.tests.utils import DirectoriesMixin from paperless.checks import binaries_check from paperless.checks import debug_mode_check diff --git a/src/paperless/tests/test_settings.py b/src/paperless/tests/test_settings.py index 44ca46ec4..710283991 100644 --- a/src/paperless/tests/test_settings.py +++ b/src/paperless/tests/test_settings.py @@ -1,9 +1,10 @@ import datetime import os -from unittest import mock from unittest import TestCase +from unittest import mock from celery.schedules import crontab + from paperless.settings import _parse_beat_schedule from paperless.settings import _parse_ignore_dates from paperless.settings import _parse_redis_url diff --git a/src/paperless/tests/test_signals.py b/src/paperless/tests/test_signals.py index 1a4d7892f..0b1ca1b22 100644 --- a/src/paperless/tests/test_signals.py +++ b/src/paperless/tests/test_signals.py @@ -1,5 +1,6 @@ from django.http import HttpRequest from django.test import TestCase + from paperless.signals import handle_failed_login diff --git a/src/paperless/tests/test_websockets.py b/src/paperless/tests/test_websockets.py index cebbddf39..bf838821a 100644 --- a/src/paperless/tests/test_websockets.py +++ b/src/paperless/tests/test_websockets.py @@ -2,10 +2,10 @@ from unittest import mock from channels.layers import get_channel_layer from channels.testing import WebsocketCommunicator -from django.test import override_settings from django.test import TestCase -from paperless.asgi import application +from django.test import override_settings +from paperless.asgi import application TEST_CHANNEL_LAYERS = { "default": { diff --git a/src/paperless/urls.py b/src/paperless/urls.py index 217268508..c2b72d7b9 100644 --- a/src/paperless/urls.py +++ b/src/paperless/urls.py @@ -7,6 +7,9 @@ from django.urls import re_path from django.utils.translation import gettext_lazy as _ from django.views.decorators.csrf import csrf_exempt from django.views.generic import RedirectView +from rest_framework.authtoken import views +from rest_framework.routers import DefaultRouter + from documents.views import AcknowledgeTasksView from documents.views import BulkDownloadView from documents.views import BulkEditView @@ -32,8 +35,6 @@ from paperless.views import UserViewSet from paperless_mail.views import MailAccountTestView from paperless_mail.views import MailAccountViewSet from paperless_mail.views import MailRuleViewSet -from rest_framework.authtoken import views -from rest_framework.routers import DefaultRouter api_router = DefaultRouter() api_router.register(r"correspondents", CorrespondentViewSet) diff --git a/src/paperless/views.py b/src/paperless/views.py index 00945e5fb..588b534e3 100644 --- a/src/paperless/views.py +++ b/src/paperless/views.py @@ -6,15 +6,16 @@ from django.db.models.functions import Lower from django.http import HttpResponse from django.views.generic import View from django_filters.rest_framework import DjangoFilterBackend +from rest_framework.filters import OrderingFilter +from rest_framework.pagination import PageNumberPagination +from rest_framework.permissions import IsAuthenticated +from rest_framework.viewsets import ModelViewSet + from documents.permissions import PaperlessObjectPermissions from paperless.filters import GroupFilterSet from paperless.filters import UserFilterSet from paperless.serialisers import GroupSerializer from paperless.serialisers import UserSerializer -from rest_framework.filters import OrderingFilter -from rest_framework.pagination import PageNumberPagination -from rest_framework.permissions import IsAuthenticated -from rest_framework.viewsets import ModelViewSet class StandardPagination(PageNumberPagination): diff --git a/src/paperless_mail/admin.py b/src/paperless_mail/admin.py index 07582cc0f..9f2b09077 100644 --- a/src/paperless_mail/admin.py +++ b/src/paperless_mail/admin.py @@ -1,6 +1,7 @@ from django import forms from django.contrib import admin from django.utils.translation import gettext_lazy as _ + from paperless_mail.models import MailAccount from paperless_mail.models import MailRule from paperless_mail.models import ProcessedMail diff --git a/src/paperless_mail/apps.py b/src/paperless_mail/apps.py index 719400e76..a07a059b4 100644 --- a/src/paperless_mail/apps.py +++ b/src/paperless_mail/apps.py @@ -1,6 +1,7 @@ from django.apps import AppConfig from django.conf import settings from django.utils.translation import gettext_lazy as _ + from paperless_mail.signals import mail_consumer_declaration diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.py index 1014e4035..e540ae0e0 100644 --- a/src/paperless_mail/mail.py +++ b/src/paperless_mail/mail.py @@ -21,6 +21,16 @@ from django.conf import settings from django.db import DatabaseError from django.utils.timezone import is_naive from django.utils.timezone import make_aware +from imap_tools import AND +from imap_tools import NOT +from imap_tools import MailBox +from imap_tools import MailboxFolderSelectError +from imap_tools import MailBoxUnencrypted +from imap_tools import MailMessage +from imap_tools import MailMessageFlags +from imap_tools.mailbox import MailBoxTls +from imap_tools.query import LogicOperator + from documents.data_models import ConsumableDocument from documents.data_models import DocumentMetadataOverrides from documents.data_models import DocumentSource @@ -28,15 +38,6 @@ from documents.loggers import LoggingMixin from documents.models import Correspondent from documents.parsers import is_mime_type_supported from documents.tasks import consume_file -from imap_tools import AND -from imap_tools import MailBox -from imap_tools import MailboxFolderSelectError -from imap_tools import MailBoxUnencrypted -from imap_tools import MailMessage -from imap_tools import MailMessageFlags -from imap_tools import NOT -from imap_tools.mailbox import MailBoxTls -from imap_tools.query import LogicOperator from paperless_mail.models import MailAccount from paperless_mail.models import MailRule from paperless_mail.models import ProcessedMail diff --git a/src/paperless_mail/management/commands/mail_fetcher.py b/src/paperless_mail/management/commands/mail_fetcher.py index e2bc8262c..0bdb5fe96 100644 --- a/src/paperless_mail/management/commands/mail_fetcher.py +++ b/src/paperless_mail/management/commands/mail_fetcher.py @@ -1,4 +1,5 @@ from django.core.management.base import BaseCommand + from paperless_mail import tasks diff --git a/src/paperless_mail/migrations/0001_initial.py b/src/paperless_mail/migrations/0001_initial.py index dbc6e467f..6fbec2892 100644 --- a/src/paperless_mail/migrations/0001_initial.py +++ b/src/paperless_mail/migrations/0001_initial.py @@ -1,7 +1,8 @@ # Generated by Django 3.1.3 on 2020-11-15 22:54 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/paperless_mail/migrations/0003_auto_20201118_1940.py b/src/paperless_mail/migrations/0003_auto_20201118_1940.py index 30a882b03..053cd6788 100644 --- a/src/paperless_mail/migrations/0003_auto_20201118_1940.py +++ b/src/paperless_mail/migrations/0003_auto_20201118_1940.py @@ -1,6 +1,7 @@ # Generated by Django 3.1.3 on 2020-11-18 19:40 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/paperless_mail/migrations/0004_mailrule_order.py b/src/paperless_mail/migrations/0004_mailrule_order.py index 71b404185..04e7e48ff 100644 --- a/src/paperless_mail/migrations/0004_mailrule_order.py +++ b/src/paperless_mail/migrations/0004_mailrule_order.py @@ -1,6 +1,7 @@ # Generated by Django 3.1.3 on 2020-11-21 21:51 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/paperless_mail/migrations/0005_help_texts.py b/src/paperless_mail/migrations/0005_help_texts.py index 2d7a543b3..f9421e251 100644 --- a/src/paperless_mail/migrations/0005_help_texts.py +++ b/src/paperless_mail/migrations/0005_help_texts.py @@ -1,6 +1,7 @@ # Generated by Django 3.1.3 on 2020-11-22 10:36 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/paperless_mail/migrations/0006_auto_20210101_2340.py b/src/paperless_mail/migrations/0006_auto_20210101_2340.py index 90d768842..fa84af978 100644 --- a/src/paperless_mail/migrations/0006_auto_20210101_2340.py +++ b/src/paperless_mail/migrations/0006_auto_20210101_2340.py @@ -1,7 +1,8 @@ # Generated by Django 3.1.4 on 2021-01-01 23:40 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/paperless_mail/migrations/0007_auto_20210106_0138.py b/src/paperless_mail/migrations/0007_auto_20210106_0138.py index 3325a86f7..5752a3b42 100644 --- a/src/paperless_mail/migrations/0007_auto_20210106_0138.py +++ b/src/paperless_mail/migrations/0007_auto_20210106_0138.py @@ -1,6 +1,7 @@ # Generated by Django 3.1.5 on 2021-01-06 01:38 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/paperless_mail/migrations/0008_auto_20210516_0940.py b/src/paperless_mail/migrations/0008_auto_20210516_0940.py index c25852c7d..6b7d68574 100644 --- a/src/paperless_mail/migrations/0008_auto_20210516_0940.py +++ b/src/paperless_mail/migrations/0008_auto_20210516_0940.py @@ -1,6 +1,7 @@ # Generated by Django 3.2.3 on 2021-05-16 09:40 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/paperless_mail/migrations/0009_alter_mailrule_action_alter_mailrule_folder.py b/src/paperless_mail/migrations/0009_alter_mailrule_action_alter_mailrule_folder.py index 7eff52691..c8eed5dea 100644 --- a/src/paperless_mail/migrations/0009_alter_mailrule_action_alter_mailrule_folder.py +++ b/src/paperless_mail/migrations/0009_alter_mailrule_action_alter_mailrule_folder.py @@ -1,6 +1,7 @@ # Generated by Django 4.0.3 on 2022-03-28 17:40 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/paperless_mail/migrations/0009_mailrule_assign_tags.py b/src/paperless_mail/migrations/0009_mailrule_assign_tags.py index fe2447e62..fa466589c 100644 --- a/src/paperless_mail/migrations/0009_mailrule_assign_tags.py +++ b/src/paperless_mail/migrations/0009_mailrule_assign_tags.py @@ -1,6 +1,7 @@ # Generated by Django 3.2.12 on 2022-03-11 15:00 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/paperless_mail/migrations/0012_alter_mailrule_assign_tags.py b/src/paperless_mail/migrations/0012_alter_mailrule_assign_tags.py index 610237f3b..d1fe98cab 100644 --- a/src/paperless_mail/migrations/0012_alter_mailrule_assign_tags.py +++ b/src/paperless_mail/migrations/0012_alter_mailrule_assign_tags.py @@ -1,6 +1,7 @@ # Generated by Django 3.2.12 on 2022-03-11 16:21 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/paperless_mail/migrations/0014_alter_mailrule_action.py b/src/paperless_mail/migrations/0014_alter_mailrule_action.py index 6d3a369cd..4ec57e505 100644 --- a/src/paperless_mail/migrations/0014_alter_mailrule_action.py +++ b/src/paperless_mail/migrations/0014_alter_mailrule_action.py @@ -1,6 +1,7 @@ # Generated by Django 4.0.4 on 2022-04-18 22:57 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/paperless_mail/migrations/0015_alter_mailrule_action.py b/src/paperless_mail/migrations/0015_alter_mailrule_action.py index 62a44e6aa..83ffe5488 100644 --- a/src/paperless_mail/migrations/0015_alter_mailrule_action.py +++ b/src/paperless_mail/migrations/0015_alter_mailrule_action.py @@ -1,6 +1,7 @@ # Generated by Django 4.0.4 on 2022-05-29 13:21 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/paperless_mail/migrations/0016_mailrule_consumption_scope.py b/src/paperless_mail/migrations/0016_mailrule_consumption_scope.py index ea54bce1b..21af834c5 100644 --- a/src/paperless_mail/migrations/0016_mailrule_consumption_scope.py +++ b/src/paperless_mail/migrations/0016_mailrule_consumption_scope.py @@ -1,6 +1,7 @@ # Generated by Django 4.0.4 on 2022-07-11 22:02 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/paperless_mail/migrations/0017_mailaccount_owner_mailrule_owner.py b/src/paperless_mail/migrations/0017_mailaccount_owner_mailrule_owner.py index 5eeccf440..52748f639 100644 --- a/src/paperless_mail/migrations/0017_mailaccount_owner_mailrule_owner.py +++ b/src/paperless_mail/migrations/0017_mailaccount_owner_mailrule_owner.py @@ -1,8 +1,9 @@ # Generated by Django 4.1.3 on 2022-12-06 04:48 -from django.conf import settings -from django.db import migrations, models import django.db.models.deletion +from django.conf import settings +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/paperless_mail/migrations/0018_processedmail.py b/src/paperless_mail/migrations/0018_processedmail.py index 93ca64dda..cfeb55d0a 100644 --- a/src/paperless_mail/migrations/0018_processedmail.py +++ b/src/paperless_mail/migrations/0018_processedmail.py @@ -1,9 +1,10 @@ # Generated by Django 4.1.5 on 2023-03-03 18:38 -from django.conf import settings -from django.db import migrations, models import django.db.models.deletion import django.utils.timezone +from django.conf import settings +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/paperless_mail/migrations/0019_mailrule_filter_to.py b/src/paperless_mail/migrations/0019_mailrule_filter_to.py index 5089670b0..8951be290 100644 --- a/src/paperless_mail/migrations/0019_mailrule_filter_to.py +++ b/src/paperless_mail/migrations/0019_mailrule_filter_to.py @@ -1,6 +1,7 @@ # Generated by Django 4.1.7 on 2023-03-11 21:08 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/paperless_mail/migrations/0020_mailaccount_is_token.py b/src/paperless_mail/migrations/0020_mailaccount_is_token.py index 98a48ec51..81ce50a19 100644 --- a/src/paperless_mail/migrations/0020_mailaccount_is_token.py +++ b/src/paperless_mail/migrations/0020_mailaccount_is_token.py @@ -1,6 +1,7 @@ # Generated by Django 4.1.7 on 2023-03-22 17:51 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/paperless_mail/migrations/0021_alter_mailaccount_password.py b/src/paperless_mail/migrations/0021_alter_mailaccount_password.py index 2c0f68065..0c012b98b 100644 --- a/src/paperless_mail/migrations/0021_alter_mailaccount_password.py +++ b/src/paperless_mail/migrations/0021_alter_mailaccount_password.py @@ -1,6 +1,7 @@ # Generated by Django 4.1.7 on 2023-04-20 15:03 -from django.db import migrations, models +from django.db import migrations +from django.db import models class Migration(migrations.Migration): diff --git a/src/paperless_mail/models.py b/src/paperless_mail/models.py index a9165b248..f9981be8f 100644 --- a/src/paperless_mail/models.py +++ b/src/paperless_mail/models.py @@ -1,8 +1,9 @@ -import documents.models as document_models from django.db import models from django.utils import timezone from django.utils.translation import gettext_lazy as _ +import documents.models as document_models + class MailAccount(document_models.ModelWithOwner): class Meta: diff --git a/src/paperless_mail/parsers.py b/src/paperless_mail/parsers.py index 4ce8a6019..4d8c03a18 100644 --- a/src/paperless_mail/parsers.py +++ b/src/paperless_mail/parsers.py @@ -10,13 +10,14 @@ from bleach import linkify from django.conf import settings from django.utils.timezone import is_naive from django.utils.timezone import make_aware -from documents.parsers import DocumentParser -from documents.parsers import make_thumbnail_from_pdf -from documents.parsers import ParseError from humanfriendly import format_size from imap_tools import MailMessage from tika import parser +from documents.parsers import DocumentParser +from documents.parsers import ParseError +from documents.parsers import make_thumbnail_from_pdf + class MailDocumentParser(DocumentParser): """ diff --git a/src/paperless_mail/serialisers.py b/src/paperless_mail/serialisers.py index e04a5c066..41dea9033 100644 --- a/src/paperless_mail/serialisers.py +++ b/src/paperless_mail/serialisers.py @@ -1,10 +1,11 @@ +from rest_framework import serializers + from documents.serialisers import CorrespondentField from documents.serialisers import DocumentTypeField from documents.serialisers import OwnedObjectSerializer from documents.serialisers import TagsField from paperless_mail.models import MailAccount from paperless_mail.models import MailRule -from rest_framework import serializers class ObfuscatedPasswordField(serializers.Field): diff --git a/src/paperless_mail/tasks.py b/src/paperless_mail/tasks.py index 5c92233de..ab013a41e 100644 --- a/src/paperless_mail/tasks.py +++ b/src/paperless_mail/tasks.py @@ -1,6 +1,7 @@ import logging from celery import shared_task + from paperless_mail.mail import MailAccountHandler from paperless_mail.mail import MailError from paperless_mail.models import MailAccount diff --git a/src/paperless_mail/tests/test_api.py b/src/paperless_mail/tests/test_api.py index 64b651970..28a369c6c 100644 --- a/src/paperless_mail/tests/test_api.py +++ b/src/paperless_mail/tests/test_api.py @@ -2,6 +2,9 @@ import json from unittest import mock from django.contrib.auth.models import User +from rest_framework import status +from rest_framework.test import APITestCase + from documents.models import Correspondent from documents.models import DocumentType from documents.models import Tag @@ -9,8 +12,6 @@ from documents.tests.utils import DirectoriesMixin from paperless_mail.models import MailAccount from paperless_mail.models import MailRule from paperless_mail.tests.test_mail import BogusMailBox -from rest_framework import status -from rest_framework.test import APITestCase class TestAPIMailAccounts(DirectoriesMixin, APITestCase): diff --git a/src/paperless_mail/tests/test_live_mail.py b/src/paperless_mail/tests/test_live_mail.py index 757bc5f4f..89029f5fd 100644 --- a/src/paperless_mail/tests/test_live_mail.py +++ b/src/paperless_mail/tests/test_live_mail.py @@ -2,11 +2,13 @@ import os import pytest from django.test import TestCase + from paperless_mail.mail import MailAccountHandler from paperless_mail.mail import MailError from paperless_mail.models import MailAccount from paperless_mail.models import MailRule + # Only run if the environment is setup # And the environment is not empty (forks, I think) @pytest.mark.skipif( diff --git a/src/paperless_mail/tests/test_mail.py b/src/paperless_mail/tests/test_mail.py index 4ad79563b..5f75e6710 100644 --- a/src/paperless_mail/tests/test_mail.py +++ b/src/paperless_mail/tests/test_mail.py @@ -12,21 +12,22 @@ from unittest import mock from django.core.management import call_command from django.db import DatabaseError from django.test import TestCase -from documents.models import Correspondent -from documents.tests.utils import DirectoriesMixin -from documents.tests.utils import FileSystemAssertsMixin +from imap_tools import NOT from imap_tools import EmailAddress from imap_tools import FolderInfo from imap_tools import MailboxFolderSelectError from imap_tools import MailboxLoginError from imap_tools import MailMessage from imap_tools import MailMessageFlags -from imap_tools import NOT + +from documents.models import Correspondent +from documents.tests.utils import DirectoriesMixin +from documents.tests.utils import FileSystemAssertsMixin from paperless_mail import tasks -from paperless_mail.mail import apply_mail_action from paperless_mail.mail import MailAccountHandler from paperless_mail.mail import MailError from paperless_mail.mail import TagMailAction +from paperless_mail.mail import apply_mail_action from paperless_mail.models import MailAccount from paperless_mail.models import MailRule diff --git a/src/paperless_mail/tests/test_parsers.py b/src/paperless_mail/tests/test_parsers.py index 3515cfbf4..e6cae1121 100644 --- a/src/paperless_mail/tests/test_parsers.py +++ b/src/paperless_mail/tests/test_parsers.py @@ -3,6 +3,7 @@ import os from unittest import mock from django.test import TestCase + from documents.parsers import ParseError from documents.tests.utils import FileSystemAssertsMixin from paperless_mail.parsers import MailDocumentParser diff --git a/src/paperless_mail/tests/test_parsers_live.py b/src/paperless_mail/tests/test_parsers_live.py index 1ff42b6dd..1b911453d 100644 --- a/src/paperless_mail/tests/test_parsers_live.py +++ b/src/paperless_mail/tests/test_parsers_live.py @@ -6,13 +6,14 @@ from urllib.request import urlopen import pytest from django.test import TestCase -from documents.parsers import run_convert -from documents.tests.utils import FileSystemAssertsMixin from imagehash import average_hash -from paperless_mail.parsers import MailDocumentParser from pdfminer.high_level import extract_text from PIL import Image +from documents.parsers import run_convert +from documents.tests.utils import FileSystemAssertsMixin +from paperless_mail.parsers import MailDocumentParser + class TestParserLive(FileSystemAssertsMixin, TestCase): SAMPLE_FILES = os.path.join(os.path.dirname(__file__), "samples") diff --git a/src/paperless_mail/views.py b/src/paperless_mail/views.py index e2bee34ff..74c170b0c 100644 --- a/src/paperless_mail/views.py +++ b/src/paperless_mail/views.py @@ -2,20 +2,21 @@ import datetime import logging from django.http import HttpResponseBadRequest -from documents.views import PassUserMixin -from paperless.views import StandardPagination -from paperless_mail.mail import get_mailbox -from paperless_mail.mail import mailbox_login -from paperless_mail.mail import MailError -from paperless_mail.models import MailAccount -from paperless_mail.models import MailRule -from paperless_mail.serialisers import MailAccountSerializer -from paperless_mail.serialisers import MailRuleSerializer from rest_framework.generics import GenericAPIView from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from rest_framework.viewsets import ModelViewSet +from documents.views import PassUserMixin +from paperless.views import StandardPagination +from paperless_mail.mail import MailError +from paperless_mail.mail import get_mailbox +from paperless_mail.mail import mailbox_login +from paperless_mail.models import MailAccount +from paperless_mail.models import MailRule +from paperless_mail.serialisers import MailAccountSerializer +from paperless_mail.serialisers import MailRuleSerializer + class MailAccountViewSet(ModelViewSet, PassUserMixin): model = MailAccount diff --git a/src/paperless_tesseract/apps.py b/src/paperless_tesseract/apps.py index 02045758b..67b90f006 100644 --- a/src/paperless_tesseract/apps.py +++ b/src/paperless_tesseract/apps.py @@ -1,4 +1,5 @@ from django.apps import AppConfig + from paperless_tesseract.signals import tesseract_consumer_declaration diff --git a/src/paperless_tesseract/checks.py b/src/paperless_tesseract/checks.py index ed5725d36..82d255005 100644 --- a/src/paperless_tesseract/checks.py +++ b/src/paperless_tesseract/checks.py @@ -3,8 +3,8 @@ import subprocess from django.conf import settings from django.core.checks import Error -from django.core.checks import register from django.core.checks import Warning +from django.core.checks import register def get_tesseract_langs(): diff --git a/src/paperless_tesseract/parsers.py b/src/paperless_tesseract/parsers.py index f3e8e21fd..d0eb98cd5 100644 --- a/src/paperless_tesseract/parsers.py +++ b/src/paperless_tesseract/parsers.py @@ -7,11 +7,12 @@ from pathlib import Path from typing import Optional from django.conf import settings -from documents.parsers import DocumentParser -from documents.parsers import make_thumbnail_from_pdf -from documents.parsers import ParseError from PIL import Image +from documents.parsers import DocumentParser +from documents.parsers import ParseError +from documents.parsers import make_thumbnail_from_pdf + class NoTextFoundException(Exception): pass @@ -310,7 +311,8 @@ class RasterisedDocumentParser(DocumentParser): # text located via OCR import ocrmypdf - from ocrmypdf import InputFileError, EncryptedPdfError + from ocrmypdf import EncryptedPdfError + from ocrmypdf import InputFileError archive_path = Path(os.path.join(self.tempdir, "archive.pdf")) sidecar_file = Path(os.path.join(self.tempdir, "sidecar.txt")) diff --git a/src/paperless_tesseract/tests/test_checks.py b/src/paperless_tesseract/tests/test_checks.py index fdcbf7656..79991bab1 100644 --- a/src/paperless_tesseract/tests/test_checks.py +++ b/src/paperless_tesseract/tests/test_checks.py @@ -1,8 +1,9 @@ from unittest import mock from django.core.checks import ERROR -from django.test import override_settings from django.test import TestCase +from django.test import override_settings + from paperless_tesseract import check_default_language_available diff --git a/src/paperless_tesseract/tests/test_parser.py b/src/paperless_tesseract/tests/test_parser.py index 5cbbc4d55..fea4f2ff9 100644 --- a/src/paperless_tesseract/tests/test_parser.py +++ b/src/paperless_tesseract/tests/test_parser.py @@ -5,14 +5,15 @@ import uuid from typing import ContextManager from unittest import mock -from django.test import override_settings from django.test import TestCase +from django.test import override_settings + from documents.parsers import ParseError from documents.parsers import run_convert from documents.tests.utils import DirectoriesMixin from documents.tests.utils import FileSystemAssertsMixin -from paperless_tesseract.parsers import post_process_text from paperless_tesseract.parsers import RasterisedDocumentParser +from paperless_tesseract.parsers import post_process_text image_to_string_calls = [] diff --git a/src/paperless_text/apps.py b/src/paperless_text/apps.py index 61f5eb7ef..1acc361aa 100644 --- a/src/paperless_text/apps.py +++ b/src/paperless_text/apps.py @@ -1,4 +1,5 @@ from django.apps import AppConfig + from paperless_text.signals import text_consumer_declaration diff --git a/src/paperless_text/parsers.py b/src/paperless_text/parsers.py index 4889c54df..37e4ca1a6 100644 --- a/src/paperless_text/parsers.py +++ b/src/paperless_text/parsers.py @@ -1,11 +1,12 @@ import os from django.conf import settings -from documents.parsers import DocumentParser from PIL import Image from PIL import ImageDraw from PIL import ImageFont +from documents.parsers import DocumentParser + class TextDocumentParser(DocumentParser): """ diff --git a/src/paperless_text/tests/test_parser.py b/src/paperless_text/tests/test_parser.py index 76a8b8498..4e7f19b33 100644 --- a/src/paperless_text/tests/test_parser.py +++ b/src/paperless_text/tests/test_parser.py @@ -1,6 +1,7 @@ import os from django.test import TestCase + from documents.tests.utils import DirectoriesMixin from documents.tests.utils import FileSystemAssertsMixin from paperless_text.parsers import TextDocumentParser diff --git a/src/paperless_tika/apps.py b/src/paperless_tika/apps.py index 012986543..6fad68df8 100644 --- a/src/paperless_tika/apps.py +++ b/src/paperless_tika/apps.py @@ -1,5 +1,6 @@ from django.apps import AppConfig from django.conf import settings + from paperless_tika.signals import tika_consumer_declaration diff --git a/src/paperless_tika/parsers.py b/src/paperless_tika/parsers.py index ea6a83f6c..779abbe59 100644 --- a/src/paperless_tika/parsers.py +++ b/src/paperless_tika/parsers.py @@ -4,11 +4,12 @@ from pathlib import Path import dateutil.parser import requests from django.conf import settings -from documents.parsers import DocumentParser -from documents.parsers import make_thumbnail_from_pdf -from documents.parsers import ParseError from tika import parser +from documents.parsers import DocumentParser +from documents.parsers import ParseError +from documents.parsers import make_thumbnail_from_pdf + class TikaDocumentParser(DocumentParser): """ diff --git a/src/paperless_tika/tests/test_live_tika.py b/src/paperless_tika/tests/test_live_tika.py index 60c2b96a4..766517965 100644 --- a/src/paperless_tika/tests/test_live_tika.py +++ b/src/paperless_tika/tests/test_live_tika.py @@ -5,6 +5,7 @@ from typing import Final import pytest from django.test import TestCase + from paperless_tika.parsers import TikaDocumentParser diff --git a/src/paperless_tika/tests/test_tika_parser.py b/src/paperless_tika/tests/test_tika_parser.py index 20e846850..4f540f3c0 100644 --- a/src/paperless_tika/tests/test_tika_parser.py +++ b/src/paperless_tika/tests/test_tika_parser.py @@ -3,13 +3,14 @@ import os from pathlib import Path from unittest import mock -from django.test import override_settings from django.test import TestCase -from documents.parsers import ParseError -from paperless_tika.parsers import TikaDocumentParser +from django.test import override_settings from requests import Response from rest_framework import status +from documents.parsers import ParseError +from paperless_tika.parsers import TikaDocumentParser + class TestTikaParser(TestCase): def setUp(self) -> None: