From ff2d88493b41eedcc1451e2775dbfb43bc794c35 Mon Sep 17 00:00:00 2001 From: Jordi Loyzaga Date: Tue, 17 Sep 2024 02:07:13 -0600 Subject: [PATCH] Migrated back to flake8 --- Makefile | 2 +- lockbox/storage/models.py | 8 ++-- poetry.lock | 93 +++++++++++++++++++++++++++------------ pyproject.toml | 14 ++---- requirements.txt | 17 ++++--- requirements_test.txt | 39 ++++++++-------- 6 files changed, 103 insertions(+), 70 deletions(-) diff --git a/Makefile b/Makefile index 38b0dd6..78386e4 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ lint: - @ruff check $(shell git diff --diff-filter=ACM --name-only HEAD | grep '\.py$$' ) --config=./pyproject.toml + @flake8 $(shell git diff --diff-filter=ACM --name-only HEAD | grep '\.py$$' ) stampreqs: poetry export --without-hashes --format=requirements.txt > requirements.txt diff --git a/lockbox/storage/models.py b/lockbox/storage/models.py index 7cd56c0..263e7e3 100644 --- a/lockbox/storage/models.py +++ b/lockbox/storage/models.py @@ -3,7 +3,6 @@ from pathlib import Path from common.constants import UPLOAD_STATUS_TYPES, UPLOAD_ERROR_CODES from common.models import LockboxBase from common.utils import get_config, get_max_size_chunk_bytes -from django.core.files.uploadedfile import UploadedFile from django.db import models, transaction from django.utils import timezone from django.utils.translation import gettext_lazy as _ @@ -12,11 +11,12 @@ from hashlib import md5 class UploadError(Exception): - + def __init__(self, *args, **kwargs): self.code = kwargs.pop("code") super().__init__(*args, **kwargs) + def upload_to_fielpath(instance, filename): return Path(str(instance.lid)).joinpath(f"{filename}{settings.INCOMPLETE_EXT}") @@ -76,7 +76,7 @@ class File(LockboxBase): null=False, blank=False, default=False, - verbose_name = _("expires"), + verbose_name=_("expires"), help_text=_("will be scrubbed on 'date_expires'"), ) @@ -135,7 +135,6 @@ class File(LockboxBase): name = self.file.name return f"{name} ({self.lid})" - class Meta: verbose_name = _("file") verbose_name_plural = _("files") @@ -214,7 +213,6 @@ class File(LockboxBase): if not self.max_size_chunk_bytes: self.max_size_chunk_bytes = get_max_size_chunk_bytes() return super().save(*args, **kwargs) - def delete(self, *args, **kwargs): diff --git a/poetry.lock b/poetry.lock index 5e9ce0a..e7d5573 100644 --- a/poetry.lock +++ b/poetry.lock @@ -158,6 +158,38 @@ files = [ Django = ">=3.2" djangorestframework = ">=3.14.0" +[[package]] +name = "flake8" +version = "7.1.1" +description = "the modular source code checker: pep8 pyflakes and co" +optional = false +python-versions = ">=3.8.1" +files = [ + {file = "flake8-7.1.1-py2.py3-none-any.whl", hash = "sha256:597477df7860daa5aa0fdd84bf5208a043ab96b8e96ab708770ae0364dd03213"}, + {file = "flake8-7.1.1.tar.gz", hash = "sha256:049d058491e228e03e67b390f311bbf88fce2dbaa8fa673e7aea87b7198b8d38"}, +] + +[package.dependencies] +mccabe = ">=0.7.0,<0.8.0" +pycodestyle = ">=2.12.0,<2.13.0" +pyflakes = ">=3.2.0,<3.3.0" + +[[package]] +name = "flake8-pyproject" +version = "1.2.3" +description = "Flake8 plug-in loading the configuration from pyproject.toml" +optional = false +python-versions = ">= 3.6" +files = [ + {file = "flake8_pyproject-1.2.3-py3-none-any.whl", hash = "sha256:6249fe53545205af5e76837644dc80b4c10037e73a0e5db87ff562d75fb5bd4a"}, +] + +[package.dependencies] +Flake8 = ">=5" + +[package.extras] +dev = ["pyTest", "pyTest-cov"] + [[package]] name = "iniconfig" version = "2.0.0" @@ -169,6 +201,17 @@ files = [ {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, ] +[[package]] +name = "mccabe" +version = "0.7.0" +description = "McCabe checker, plugin for flake8" +optional = false +python-versions = ">=3.6" +files = [ + {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, + {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, +] + [[package]] name = "packaging" version = "24.1" @@ -195,6 +238,28 @@ files = [ dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] +[[package]] +name = "pycodestyle" +version = "2.12.1" +description = "Python style guide checker" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pycodestyle-2.12.1-py2.py3-none-any.whl", hash = "sha256:46f0fb92069a7c28ab7bb558f05bfc0110dac69a0cd23c61ea0040283a9d78b3"}, + {file = "pycodestyle-2.12.1.tar.gz", hash = "sha256:6838eae08bbce4f6accd5d5572075c63626a15ee3e6f842df996bf62f6d73521"}, +] + +[[package]] +name = "pyflakes" +version = "3.2.0" +description = "passive checker of Python programs" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pyflakes-3.2.0-py2.py3-none-any.whl", hash = "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a"}, + {file = "pyflakes-3.2.0.tar.gz", hash = "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f"}, +] + [[package]] name = "pytest" version = "8.3.2" @@ -265,32 +330,6 @@ files = [ [package.extras] cli = ["click (>=5.0)"] -[[package]] -name = "ruff" -version = "0.2.2" -description = "An extremely fast Python linter and code formatter, written in Rust." -optional = false -python-versions = ">=3.7" -files = [ - {file = "ruff-0.2.2-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:0a9efb032855ffb3c21f6405751d5e147b0c6b631e3ca3f6b20f917572b97eb6"}, - {file = "ruff-0.2.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:d450b7fbff85913f866a5384d8912710936e2b96da74541c82c1b458472ddb39"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ecd46e3106850a5c26aee114e562c329f9a1fbe9e4821b008c4404f64ff9ce73"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5e22676a5b875bd72acd3d11d5fa9075d3a5f53b877fe7b4793e4673499318ba"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1695700d1e25a99d28f7a1636d85bafcc5030bba9d0578c0781ba1790dbcf51c"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:b0c232af3d0bd8f521806223723456ffebf8e323bd1e4e82b0befb20ba18388e"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f63d96494eeec2fc70d909393bcd76c69f35334cdbd9e20d089fb3f0640216ca"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6a61ea0ff048e06de273b2e45bd72629f470f5da8f71daf09fe481278b175001"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5e1439c8f407e4f356470e54cdecdca1bd5439a0673792dbe34a2b0a551a2fe3"}, - {file = "ruff-0.2.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:940de32dc8853eba0f67f7198b3e79bc6ba95c2edbfdfac2144c8235114d6726"}, - {file = "ruff-0.2.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0c126da55c38dd917621552ab430213bdb3273bb10ddb67bc4b761989210eb6e"}, - {file = "ruff-0.2.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:3b65494f7e4bed2e74110dac1f0d17dc8e1f42faaa784e7c58a98e335ec83d7e"}, - {file = "ruff-0.2.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:1ec49be4fe6ddac0503833f3ed8930528e26d1e60ad35c2446da372d16651ce9"}, - {file = "ruff-0.2.2-py3-none-win32.whl", hash = "sha256:d920499b576f6c68295bc04e7b17b6544d9d05f196bb3aac4358792ef6f34325"}, - {file = "ruff-0.2.2-py3-none-win_amd64.whl", hash = "sha256:cc9a91ae137d687f43a44c900e5d95e9617cb37d4c989e462980ba27039d239d"}, - {file = "ruff-0.2.2-py3-none-win_arm64.whl", hash = "sha256:c9d15fc41e6054bfc7200478720570078f0b41c9ae4f010bcc16bd6f4d1aacdd"}, - {file = "ruff-0.2.2.tar.gz", hash = "sha256:e62ed7f36b3068a30ba39193a14274cd706bc486fad521276458022f7bccb31d"}, -] - [[package]] name = "sqlparse" version = "0.5.1" @@ -334,4 +373,4 @@ brotli = ["brotli"] [metadata] lock-version = "2.0" python-versions = "~3.12" -content-hash = "741d7f30a1ede036db2ed47db09fab40f855d0a158fbef96acff371c2b51e517" +content-hash = "d8ff6440e16bd3eb499933ec438f2490a91e8caab975ab40505a64daab72cf9e" diff --git a/pyproject.toml b/pyproject.toml index 5525c1f..652adac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ python-dotenv = "^1.0.1" pytest = "^8.0.0" pytest-django = "^4.8.0" pytest-cov = "^4.1.0" -ruff = "^0.2.1" +flake8-pyproject = "^1.2.3" [tool.pytest.ini_options] @@ -50,7 +50,7 @@ omit = [ "lockbox/wsgi.py", ] -[tool.ruff] +[tool.flake8] exclude = [ "*/migrations/*", ".pyscripts/*", @@ -60,13 +60,6 @@ exclude = [ ".venv", "manage.py", ] -force-exclude = true - -line-length = 120 -target-version = "py312" - -[tool.ruff.lint] -select = ["ALL"] ignore = [ "ANN", "ARG001", @@ -78,7 +71,6 @@ ignore = [ "ERA001", "FIX", "N801", - "PLR0913", "Q000", "RUF012", "S101", @@ -88,6 +80,8 @@ ignore = [ "TD", "TRY", ] +max-line-length = 120 + [build-system] requires = ["poetry-core"] diff --git a/requirements.txt b/requirements.txt index c87b065..0a60155 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,8 @@ -asgiref==3.7.2 ; python_version == "3.12" -django==4.2.10 ; python_version == "3.12" -djangorestframework==3.14.0 ; python_version == "3.12" -drf-nested-routers==0.93.5 ; python_version == "3.12" -python-dotenv==1.0.1 ; python_version == "3.12" -pytz==2024.1 ; python_version == "3.12" -sqlparse==0.4.4 ; python_version == "3.12" -tzdata==2023.4 ; sys_platform == "win32" and python_version == "3.12" -whitenoise==6.6.0 ; python_version == "3.12" +asgiref==3.8.1 ; python_version >= "3.12" and python_version < "3.13" +django==4.2.15 ; python_version >= "3.12" and python_version < "3.13" +djangorestframework==3.15.2 ; python_version >= "3.12" and python_version < "3.13" +drf-nested-routers==0.93.5 ; python_version >= "3.12" and python_version < "3.13" +python-dotenv==1.0.1 ; python_version >= "3.12" and python_version < "3.13" +sqlparse==0.5.1 ; python_version >= "3.12" and python_version < "3.13" +tzdata==2024.1 ; python_version >= "3.12" and python_version < "3.13" and sys_platform == "win32" +whitenoise==6.7.0 ; python_version >= "3.12" and python_version < "3.13" diff --git a/requirements_test.txt b/requirements_test.txt index d1ba9e6..e45a05f 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,18 +1,21 @@ -asgiref==3.7.2 ; python_version == "3.12" -colorama==0.4.6 ; python_version == "3.12" and sys_platform == "win32" -coverage[toml]==7.4.1 ; python_version == "3.12" -django==4.2.10 ; python_version == "3.12" -djangorestframework==3.14.0 ; python_version == "3.12" -drf-nested-routers==0.93.5 ; python_version == "3.12" -iniconfig==2.0.0 ; python_version == "3.12" -packaging==23.2 ; python_version == "3.12" -pluggy==1.4.0 ; python_version == "3.12" -pytest-cov==4.1.0 ; python_version == "3.12" -pytest-django==4.8.0 ; python_version == "3.12" -pytest==8.0.0 ; python_version == "3.12" -python-dotenv==1.0.1 ; python_version == "3.12" -pytz==2024.1 ; python_version == "3.12" -ruff==0.2.1 ; python_version == "3.12" -sqlparse==0.4.4 ; python_version == "3.12" -tzdata==2023.4 ; sys_platform == "win32" and python_version == "3.12" -whitenoise==6.6.0 ; python_version == "3.12" +asgiref==3.8.1 ; python_version >= "3.12" and python_version < "3.13" +colorama==0.4.6 ; python_version >= "3.12" and python_version < "3.13" and sys_platform == "win32" +coverage[toml]==7.6.1 ; python_version >= "3.12" and python_version < "3.13" +django==4.2.15 ; python_version >= "3.12" and python_version < "3.13" +djangorestframework==3.15.2 ; python_version >= "3.12" and python_version < "3.13" +drf-nested-routers==0.93.5 ; python_version >= "3.12" and python_version < "3.13" +flake8-pyproject==1.2.3 ; python_version >= "3.12" and python_version < "3.13" +flake8==7.1.1 ; python_version >= "3.12" and python_version < "3.13" +iniconfig==2.0.0 ; python_version >= "3.12" and python_version < "3.13" +mccabe==0.7.0 ; python_version >= "3.12" and python_version < "3.13" +packaging==24.1 ; python_version >= "3.12" and python_version < "3.13" +pluggy==1.5.0 ; python_version >= "3.12" and python_version < "3.13" +pycodestyle==2.12.1 ; python_version >= "3.12" and python_version < "3.13" +pyflakes==3.2.0 ; python_version >= "3.12" and python_version < "3.13" +pytest-cov==4.1.0 ; python_version >= "3.12" and python_version < "3.13" +pytest-django==4.8.0 ; python_version >= "3.12" and python_version < "3.13" +pytest==8.3.2 ; python_version >= "3.12" and python_version < "3.13" +python-dotenv==1.0.1 ; python_version >= "3.12" and python_version < "3.13" +sqlparse==0.5.1 ; python_version >= "3.12" and python_version < "3.13" +tzdata==2024.1 ; python_version >= "3.12" and python_version < "3.13" and sys_platform == "win32" +whitenoise==6.7.0 ; python_version >= "3.12" and python_version < "3.13"