From b78e3b0b007c1010d327f29c9be82c9d004e6b63 Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Tue, 12 Mar 2024 07:27:57 -0700 Subject: [PATCH] Updates pre-commit hook versions and runs it against all files --- .pre-commit-config.yaml | 2 +- src/documents/classifier.py | 10 ++-------- src/documents/migrations/0014_document_checksum.py | 4 +--- src/documents/tests/utils.py | 4 +--- src/paperless_tesseract/tests/test_parser.py | 6 +----- 5 files changed, 6 insertions(+), 20 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4ee14f187..a036a11d1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -47,7 +47,7 @@ repos: exclude: "(^Pipfile\\.lock$)" # Python hooks - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.3.0' + rev: 'v0.3.2' hooks: - id: ruff - repo: https://github.com/psf/black-pre-commit-mirror diff --git a/src/documents/classifier.py b/src/documents/classifier.py index aa0eb70b6..b3787abab 100644 --- a/src/documents/classifier.py +++ b/src/documents/classifier.py @@ -237,14 +237,8 @@ class DocumentClassifier: num_storage_paths = len(set(labels_storage_path) | {-1}) - 1 logger.debug( - "{} documents, {} tag(s), {} correspondent(s), " - "{} document type(s). {} storage path(es)".format( - docs_queryset.count(), - num_tags, - num_correspondents, - num_document_types, - num_storage_paths, - ), + f"{docs_queryset.count()} documents, {num_tags} tag(s), {num_correspondents} correspondent(s), " + f"{num_document_types} document type(s). {num_storage_paths} storage path(es)", ) from sklearn.feature_extraction.text import CountVectorizer diff --git a/src/documents/migrations/0014_document_checksum.py b/src/documents/migrations/0014_document_checksum.py index deef59990..f3da30eb6 100644 --- a/src/documents/migrations/0014_document_checksum.py +++ b/src/documents/migrations/0014_document_checksum.py @@ -130,9 +130,7 @@ def set_checksums(apps, schema_editor): fg="red", ), code=colourise( - " $ echo 'DELETE FROM documents_document WHERE id = {pk};' | ./manage.py dbshell".format( - pk=document.pk, - ), + f" $ echo 'DELETE FROM documents_document WHERE id = {document.pk};' | ./manage.py dbshell", fg="green", ), line=colourise("\n{}\n".format("=" * 80), fg="white", opts=("bold",)), diff --git a/src/documents/tests/utils.py b/src/documents/tests/utils.py index ba435d5c3..abdd27017 100644 --- a/src/documents/tests/utils.py +++ b/src/documents/tests/utils.py @@ -290,9 +290,7 @@ class TestMigrations(TransactionTestCase): assert ( self.migrate_from and self.migrate_to - ), "TestCase '{}' must define migrate_from and migrate_to properties".format( - type(self).__name__, - ) + ), f"TestCase '{type(self).__name__}' must define migrate_from and migrate_to properties" self.migrate_from = [(self.app, self.migrate_from)] if self.dependencies is not None: self.migrate_from.extend(self.dependencies) diff --git a/src/paperless_tesseract/tests/test_parser.py b/src/paperless_tesseract/tests/test_parser.py index fae64742e..d63d965c5 100644 --- a/src/paperless_tesseract/tests/test_parser.py +++ b/src/paperless_tesseract/tests/test_parser.py @@ -45,11 +45,7 @@ class TestParser(DirectoriesMixin, FileSystemAssertsMixin, TestCase): self.assertEqual( result, actual_result, - "strip_exceess_whitespace({}) != '{}', but '{}'".format( - source, - result, - actual_result, - ), + f"strip_exceess_whitespace({source}) != '{result}', but '{actual_result}'", ) def test_get_text_from_pdf(self):