From ac98af34b956f085f7e4ce37f9e7ad37cc04df03 Mon Sep 17 00:00:00 2001 From: WisdomPill Date: Wed, 1 Nov 2023 15:53:33 +0200 Subject: [PATCH] Replaced flake8 and isort with ruff --- .github/workflows/ci.yml | 3 +- .ruff.toml | 129 +++++++++++++++++++++++++++++++++++++++ setup.cfg | 11 ++-- 3 files changed, 134 insertions(+), 9 deletions(-) create mode 100644 .ruff.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b5bee6c..65e0fd58 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,8 +125,7 @@ jobs: matrix: tool: - 'black' - - 'flake8' - - 'isort' + - 'ruff' - 'mypy' steps: diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 00000000..cdcc7fee --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,129 @@ +# https://beta.ruff.rs/docs/rules/ +select = [ + # rules from pyflakes +# "F", + + # rules from pycodestyle +# "E", "W", + + # rules from mccabe +# "C90", + + # rules from isort +# "I", + + # rules from pyupgrade +# "UP", + + # rules from flake8-2020 +# "YTT", + + # rules from flake8-annotations +# "ANN", + + # rules from flake8-bandit +# "S", + + # rules from flake8-blind-except +# "BLE", + + # rules from flake8-boolean-trap + # TODO: "FBT", + + # rules from flake8-bugbear + # TODO: "B", + + # rules from flake8-builtins + # TODO: "A", + + # rules from flake8-commas +# "COM", + + # rules from flake8-comprehensions +# "C4", + + # rules from flake8-datetimez + # TODO: "DTZ", + + # rules from flake8-debugger +# "T10", + + # rules from flake8-django + # TODO: "DJ", + + # rules from flake8-errmsg +# "EM", + + # rules from flake8-executable + # TODO: "EXE", + + # rules from flake8-implicit-str-concat +# "ISC", + + # rules from flake8-import-conventions +# "ICN", + + # rules from flake8-logging-format + # TODO: "G", + + # rules from flake8-no-pep420 + # TODO: "INP", + + # rules from flake8-pie + # TODO: "PIE", + + # rules from flake8-print +# "T20", + + # rules from flake8-pyi +# "PYI", + + # rules from flake8-pytest-style + # TODO: "PT", + + # rules from flake8-raise +# "RSE", + + # rules from flake8-return + # TODO: "RET", + + # rules from flake8-self + # TODO: "SLF", + + # rules from flake8-simplify +# "SIM", + + # rules from flake8-tidy-imports +# "TID", + + # rules from flake8-type-checking +# "TCH", + + # rules from flake8-gettext +# "INT", + + # rules from flake8-unused-arguments + # TODO: "ARG", + + # rules from flake8-use-pathlib + # could be enabled easily + # TODO: "PTH", + + # removes unused noqa comments +# "RUF100", +] + +ignore = [ + "COM812", # missing trailing comma, covered by black + "ANN101", # ignore missing type annotation in self parameter +] + +fix = true + +# TODO: enable this when python3.6 will stop being supported, +# from april 2024 https://docs.djangoproject.com/en/4.2/releases/3.2/ +#target-version = "py36" + +#[flake8-tidy-imports] +## Disallow all relative imports. +#ban-relative-imports = "all" diff --git a/setup.cfg b/setup.cfg index b781ff50..d765124f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -69,8 +69,7 @@ multi_line_output = 3 minversion = 3.15.0 envlist = black - flake8 - isort + ruff mypy # tests against released versions py{36,37,38,39,310,311}-dj{22,31,32,40,41,42}-redislatest @@ -131,19 +130,17 @@ deps = lz4>=0.15 pyzstd>=0.15 -[testenv:{black,flake8,isort,mypy}] +[testenv:{black,ruff,mypy}] basepython = python3 envdir={toxworkdir}/lint commands = black: black --target-version py36 {posargs:--check --diff} setup.py django_redis/ tests/ - flake8: flake8 {posargs} setup.py django_redis/ tests/ - isort: isort {posargs:--check-only --diff} django_redis/ tests/ + ruff: ruff {posargs:check --show-fixes} django_redis/ tests/ mypy: mypy {posargs:--cobertura-xml-report .} django_redis tests deps = black django-stubs - flake8 - isort >= 5.0.2 + ruff lxml mypy # typing dependencies