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/Pipfile.lock b/Pipfile.lock index be69c652e..4993fa05a 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -2928,11 +2928,11 @@ }, "importlib-metadata": { "hashes": [ - "sha256:4805911c3a4ec7c3966410053e9ec6a1fecd629117df5adee56dfc9432a1081e", - "sha256:f238736bb06590ae52ac1fab06a3a9ef1d8dce2b7a35b5ab329371d6c8f5d2cc" + "sha256:198f568f3230878cb1b44fbd7975f87906c22336dba2e4a7f05278c281fbd792", + "sha256:f4bc4c0c070c490abf4ce96d715f68e95923320370efb66143df00199bb6c100" ], "markers": "python_version < '3.10'", - "version": "==7.0.1" + "version": "==7.0.2" }, "incremental": { "hashes": [ @@ -3057,12 +3057,12 @@ }, "mkdocs-material": { "hashes": [ - "sha256:5f69cef6a8aaa4050b812f72b1094fda3d079b9a51cf27a247244c03ec455e97", - "sha256:d6f0c269f015e48c76291cdc79efb70f7b33bbbf42d649cfe475522ebee61b1f" + "sha256:5cbe17fee4e3b4980c8420a04cc762d8dc052ef1e10532abd4fce88e5ea9ce6a", + "sha256:d8e4caae576312a88fd2609b81cf43d233cdbe36860d67a68702b018b425bd87" ], "index": "pypi", "markers": "python_version >= '3.8'", - "version": "==9.5.12" + "version": "==9.5.13" }, "mkdocs-material-extensions": { "hashes": [ @@ -3132,11 +3132,11 @@ }, "packaging": { "hashes": [ - "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5", - "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7" + "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5", + "sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9" ], "markers": "python_version >= '3.7'", - "version": "==23.2" + "version": "==24.0" }, "paginate": { "hashes": [ @@ -3284,11 +3284,11 @@ }, "pymdown-extensions": { "hashes": [ - "sha256:6ca215bc57bc12bf32b414887a68b810637d039124ed9b2e5bd3325cbb2c050c", - "sha256:c0d64d5cf62566f59e6b2b690a4095c931107c250a8c8e1351c1de5f6b036deb" + "sha256:c70e146bdd83c744ffc766b4671999796aba18842b268510a329f7f64700d584", + "sha256:f5cc7000d7ff0d1ce9395d216017fa4df3dde800afb1fb72d1c7d3fd35e710f4" ], "markers": "python_version >= '3.8'", - "version": "==10.7" + "version": "==10.7.1" }, "pyopenssl": { "hashes": [ @@ -3299,12 +3299,12 @@ }, "pytest": { "hashes": [ - "sha256:d4051d623a2e0b7e51960ba963193b09ce6daeb9759a451844a21e4ddedfc1bd", - "sha256:edfaaef32ce5172d5466b5127b42e0d6d35ebbe4453f0e3505d96afd93f6b096" + "sha256:2a8386cfc11fa9d2c50ee7b2a57e7d898ef90470a7a34c4b949ff59662bb78b7", + "sha256:ac978141a75948948817d360297b7aae0fcb9d6ff6bc9ec6d514b85d5a65c044" ], "index": "pypi", "markers": "python_version >= '3.8'", - "version": "==8.0.2" + "version": "==8.1.1" }, "pytest-cov": { "hashes": [ @@ -3373,7 +3373,6 @@ "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3", "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427" ], - "index": "pypi", "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.9.0.post0" }, @@ -3462,6 +3461,7 @@ "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d", "sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f" ], + "markers": "python_version >= '3.6'", "version": "==6.0.1" }, "pyyaml-env-tag": { @@ -3581,27 +3581,27 @@ }, "ruff": { "hashes": [ - "sha256:0886184ba2618d815067cf43e005388967b67ab9c80df52b32ec1152ab49f53a", - "sha256:128265876c1d703e5f5e5a4543bd8be47c73a9ba223fd3989d4aa87dd06f312f", - "sha256:19eacceb4c9406f6c41af806418a26fdb23120dfe53583df76d1401c92b7c14b", - "sha256:23dbb808e2f1d68eeadd5f655485e235c102ac6f12ad31505804edced2a5ae77", - "sha256:2f7dbba46e2827dfcb0f0cc55fba8e96ba7c8700e0a866eb8cef7d1d66c25dcb", - "sha256:3ef655c51f41d5fa879f98e40c90072b567c666a7114fa2d9fe004dffba00932", - "sha256:5da894a29ec018a8293d3d17c797e73b374773943e8369cfc50495573d396933", - "sha256:755c22536d7f1889be25f2baf6fedd019d0c51d079e8417d4441159f3bcd30c2", - "sha256:7deb528029bacf845bdbb3dbb2927d8ef9b4356a5e731b10eef171e3f0a85944", - "sha256:9343690f95710f8cf251bee1013bf43030072b9f8d012fbed6ad702ef70d360a", - "sha256:a1f3ed501a42f60f4dedb7805fa8d4534e78b4e196f536bac926f805f0743d49", - "sha256:b08b356d06a792e49a12074b62222f9d4ea2a11dca9da9f68163b28c71bf1dd4", - "sha256:cc30a9053ff2f1ffb505a585797c23434d5f6c838bacfe206c0e6cf38c921a1e", - "sha256:d0d3d7ef3d4f06433d592e5f7d813314a34601e6c5be8481cccb7fa760aa243e", - "sha256:dd73fe7f4c28d317855da6a7bc4aa29a1500320818dd8f27df95f70a01b8171f", - "sha256:e1e0d4381ca88fb2b73ea0766008e703f33f460295de658f5467f6f229658c19", - "sha256:e3a4a6d46aef0a84b74fcd201a4401ea9a6cd85614f6a9435f2d33dd8cefbf83" + "sha256:0ac06a3759c3ab9ef86bbeca665d31ad3aa9a4b1c17684aadb7e61c10baa0df4", + "sha256:0c1bdd9920cab5707c26c8b3bf33a064a4ca7842d91a99ec0634fec68f9f4037", + "sha256:1231eacd4510f73222940727ac927bc5d07667a86b0cbe822024dd00343e77e9", + "sha256:2c6d613b19e9a8021be2ee1d0e27710208d1603b56f47203d0abbde906929a9b", + "sha256:5f65103b1d76e0d600cabd577b04179ff592064eaa451a70a81085930e907d0b", + "sha256:77f2612752e25f730da7421ca5e3147b213dca4f9a0f7e0b534e9562c5441f01", + "sha256:967978ac2d4506255e2f52afe70dda023fc602b283e97685c8447d036863a302", + "sha256:9966b964b2dd1107797be9ca7195002b874424d1d5472097701ae8f43eadef5d", + "sha256:9bd640a8f7dd07a0b6901fcebccedadeb1a705a50350fb86b4003b805c81385a", + "sha256:b74c3de9103bd35df2bb05d8b2899bf2dbe4efda6474ea9681280648ec4d237d", + "sha256:b83d17ff166aa0659d1e1deaf9f2f14cbe387293a906de09bc4860717eb2e2da", + "sha256:bb875c6cc87b3703aeda85f01c9aebdce3d217aeaca3c2e52e38077383f7268a", + "sha256:be75e468a6a86426430373d81c041b7605137a28f7014a72d2fc749e47f572aa", + "sha256:c8439338a6303585d27b66b4626cbde89bb3e50fa3cae86ce52c1db7449330a7", + "sha256:de8b480d8379620cbb5ea466a9e53bb467d2fb07c7eca54a4aa8576483c35d36", + "sha256:f380be9fc15a99765c9cf316b40b9da1f6ad2ab9639e551703e581a5e6da6745", + "sha256:fa78ec9418eb1ca3db392811df3376b46471ae93792a81af2d1cbb0e5dcb5142" ], "index": "pypi", "markers": "python_version >= '3.7'", - "version": "==0.3.0" + "version": "==0.3.2" }, "scipy": { "hashes": [ @@ -3756,7 +3756,6 @@ "sha256:f970663fa4f7e80401a7b0cbeec00fa801bf0287d93d48368fc3e6fa32716245", "sha256:f9b2fdca47dc855516b2d66eef3c39f2672cbf7e7a42e7e67ad2cbfcd6ba107d" ], - "index": "pypi", "markers": "python_version >= '3.8'", "version": "==4.0.0" }, 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):