From 86c2355e9be63a2565ef70e9a2eb1700c7a06955 Mon Sep 17 00:00:00 2001 From: David Vogt Date: Wed, 31 Jan 2024 08:51:43 +0100 Subject: [PATCH 1/2] chore: drop flake8, isort, and black and their plugins in favour of ruff Ruff is faster and better in almost every aspect. It can replace flake8, isort and black, do everything that these tools did, and faster. The pre-commit checks are replaced with ruff, the checks in CI as well as the links in the README. --- .flake8 | 25 ---- .github/workflows/tests.yml | 8 +- .pre-commit-config.yaml | 18 +-- .reuse/dep5 | 1 - CONTRIBUTING.md | 4 +- README.md | 2 +- poetry.lock | 260 ++++-------------------------------- pyproject.toml | 51 +++++-- 8 files changed, 82 insertions(+), 287 deletions(-) delete mode 100644 .flake8 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index c49c77e3c..000000000 --- a/.flake8 +++ /dev/null @@ -1,25 +0,0 @@ -[flake8] -ignore = - # whitespace before ':' - E203, - # too many leading ### in a block comment - E266, - # line too long (managed by black) - E501, - # Line break occurred before a binary operator (this is not PEP8 compatible) - W503, - # do not enforce existence of docstrings - D100, - D101, - D102, - D103, - D104, - D105, - D106, - D107, - # needed because of https://github.com/ambv/black/issues/144 - D202, -max-line-length = 88 -exclude = migrations snapshots .venv -max-complexity = 11 -doctests = False diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1fe4a2923..0be0768a0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -46,11 +46,11 @@ jobs: - name: Run gitlint run: poetry run gitlint --contrib contrib-title-conventional-commits - - name: Run black - run: poetry run black --check . + - name: Check code format + run: poetry run ruff format --check . - - name: Run flake8 - run: poetry run flake8 --exclude .venv + - name: Check code style + run: poetry run ruff check . - name: Run migration check run: poetry run python manage.py makemigrations --check --dry-run --no-input diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e2060f74b..de6cc6370 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,23 +1,17 @@ repos: - repo: local hooks: - - id: black + - id: ruff-format stages: [commit] - name: black + name: format code language: system - entry: black + entry: ruff format . types: [python] - - id: isort + - id: ruff-check stages: [commit] - name: isort + name: check format,import language: system - entry: isort - types: [python] - - id: flake8 - stages: [commit] - name: flake8 - language: system - entry: flake8 + entry: ruff check . types: [python] - id: reuse stages: [commit] diff --git a/.reuse/dep5 b/.reuse/dep5 index eb06cb202..adcb533dc 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -8,7 +8,6 @@ Files: .dockerignore .editorconfig .env - .flake8 .github/dependabot.yml .github/workflows/compatibility-tests.yml .github/workflows/ghcr.yml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index abadd28d2..ccbf5f534 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,9 +36,9 @@ etc. ```bash # linting -poetry run flake8 +poetry run ruff check . # format code -poetry run black . +poetry run ruff format . # running tests poetry run pytest # create migrations diff --git a/README.md b/README.md index 9bf02077d..5c2a3963a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://github.com/projectcaluma/caluma/workflows/Tests/badge.svg)](https://github.com/projectcaluma/caluma/actions?query=workflow%3ATests) [![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](https://github.com/projectcaluma/caluma/blob/main/setup.cfg#L57) -[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) +[![Ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://docs.astral.sh/ruff/) [![PyPI](https://img.shields.io/pypi/v/caluma)](https://pypi.org/project/caluma/) [![License: GPL-3.0-or-later](https://img.shields.io/github/license/projectcaluma/caluma)](https://spdx.org/licenses/GPL-3.0-or-later.html) diff --git a/poetry.lock b/poetry.lock index 5371e8062..10076a55f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -146,55 +146,6 @@ files = [ [package.dependencies] chardet = ">=3.0.2" -[[package]] -name = "black" -version = "23.3.0" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.7" -files = [ - {file = "black-23.3.0-cp310-cp310-macosx_10_16_arm64.whl", hash = "sha256:0945e13506be58bf7db93ee5853243eb368ace1c08a24c65ce108986eac65915"}, - {file = "black-23.3.0-cp310-cp310-macosx_10_16_universal2.whl", hash = "sha256:67de8d0c209eb5b330cce2469503de11bca4085880d62f1628bd9972cc3366b9"}, - {file = "black-23.3.0-cp310-cp310-macosx_10_16_x86_64.whl", hash = "sha256:7c3eb7cea23904399866c55826b31c1f55bbcd3890ce22ff70466b907b6775c2"}, - {file = "black-23.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:32daa9783106c28815d05b724238e30718f34155653d4d6e125dc7daec8e260c"}, - {file = "black-23.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:35d1381d7a22cc5b2be2f72c7dfdae4072a3336060635718cc7e1ede24221d6c"}, - {file = "black-23.3.0-cp311-cp311-macosx_10_16_arm64.whl", hash = "sha256:a8a968125d0a6a404842fa1bf0b349a568634f856aa08ffaff40ae0dfa52e7c6"}, - {file = "black-23.3.0-cp311-cp311-macosx_10_16_universal2.whl", hash = "sha256:c7ab5790333c448903c4b721b59c0d80b11fe5e9803d8703e84dcb8da56fec1b"}, - {file = "black-23.3.0-cp311-cp311-macosx_10_16_x86_64.whl", hash = "sha256:a6f6886c9869d4daae2d1715ce34a19bbc4b95006d20ed785ca00fa03cba312d"}, - {file = "black-23.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6f3c333ea1dd6771b2d3777482429864f8e258899f6ff05826c3a4fcc5ce3f70"}, - {file = "black-23.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:11c410f71b876f961d1de77b9699ad19f939094c3a677323f43d7a29855fe326"}, - {file = "black-23.3.0-cp37-cp37m-macosx_10_16_x86_64.whl", hash = "sha256:1d06691f1eb8de91cd1b322f21e3bfc9efe0c7ca1f0e1eb1db44ea367dff656b"}, - {file = "black-23.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:50cb33cac881766a5cd9913e10ff75b1e8eb71babf4c7104f2e9c52da1fb7de2"}, - {file = "black-23.3.0-cp37-cp37m-win_amd64.whl", hash = "sha256:e114420bf26b90d4b9daa597351337762b63039752bdf72bf361364c1aa05925"}, - {file = "black-23.3.0-cp38-cp38-macosx_10_16_arm64.whl", hash = "sha256:48f9d345675bb7fbc3dd85821b12487e1b9a75242028adad0333ce36ed2a6d27"}, - {file = "black-23.3.0-cp38-cp38-macosx_10_16_universal2.whl", hash = "sha256:714290490c18fb0126baa0fca0a54ee795f7502b44177e1ce7624ba1c00f2331"}, - {file = "black-23.3.0-cp38-cp38-macosx_10_16_x86_64.whl", hash = "sha256:064101748afa12ad2291c2b91c960be28b817c0c7eaa35bec09cc63aa56493c5"}, - {file = "black-23.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:562bd3a70495facf56814293149e51aa1be9931567474993c7942ff7d3533961"}, - {file = "black-23.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:e198cf27888ad6f4ff331ca1c48ffc038848ea9f031a3b40ba36aced7e22f2c8"}, - {file = "black-23.3.0-cp39-cp39-macosx_10_16_arm64.whl", hash = "sha256:3238f2aacf827d18d26db07524e44741233ae09a584273aa059066d644ca7b30"}, - {file = "black-23.3.0-cp39-cp39-macosx_10_16_universal2.whl", hash = "sha256:f0bd2f4a58d6666500542b26354978218a9babcdc972722f4bf90779524515f3"}, - {file = "black-23.3.0-cp39-cp39-macosx_10_16_x86_64.whl", hash = "sha256:92c543f6854c28a3c7f39f4d9b7694f9a6eb9d3c5e2ece488c327b6e7ea9b266"}, - {file = "black-23.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a150542a204124ed00683f0db1f5cf1c2aaaa9cc3495b7a3b5976fb136090ab"}, - {file = "black-23.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:6b39abdfb402002b8a7d030ccc85cf5afff64ee90fa4c5aebc531e3ad0175ddb"}, - {file = "black-23.3.0-py3-none-any.whl", hash = "sha256:ec751418022185b0c1bb7d7736e6933d40bbb14c14a0abcf9123d1b159f98dd4"}, - {file = "black-23.3.0.tar.gz", hash = "sha256:1c7b8d606e728a41ea1ccbd7264677e494e87cf630e399262ced92d4a8dac940"}, -] - -[package.dependencies] -click = ">=8.0.0" -mypy-extensions = ">=0.4.3" -packaging = ">=22.0" -pathspec = ">=0.9.0" -platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = {version = ">=3.10.0.0", markers = "python_version < \"3.10\""} - -[package.extras] -colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2)"] - [[package]] name = "boolean-py" version = "4.0" @@ -813,117 +764,6 @@ docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1 testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] typing = ["typing-extensions (>=4.8)"] -[[package]] -name = "flake8" -version = "6.0.0" -description = "the modular source code checker: pep8 pyflakes and co" -optional = false -python-versions = ">=3.8.1" -files = [ - {file = "flake8-6.0.0-py2.py3-none-any.whl", hash = "sha256:3833794e27ff64ea4e9cf5d410082a8b97ff1a06c16aa3d2027339cd0f1195c7"}, - {file = "flake8-6.0.0.tar.gz", hash = "sha256:c61007e76655af75e6785a931f452915b371dc48f56efd765247c8fe68f2b181"}, -] - -[package.dependencies] -mccabe = ">=0.7.0,<0.8.0" -pycodestyle = ">=2.10.0,<2.11.0" -pyflakes = ">=3.0.0,<3.1.0" - -[[package]] -name = "flake8-bugbear" -version = "23.5.9" -description = "A plugin for flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle." -optional = false -python-versions = ">=3.8.1" -files = [ - {file = "flake8-bugbear-23.5.9.tar.gz", hash = "sha256:695c84a5d7da54eb35d79a7354dbaf3aaba80de32250608868aa1c85534b2a86"}, - {file = "flake8_bugbear-23.5.9-py3-none-any.whl", hash = "sha256:631fa927fbc799e8ca636b849dd7dfc304812287137b6ecb3277821f028bee40"}, -] - -[package.dependencies] -attrs = ">=19.2.0" -flake8 = ">=6.0.0" - -[package.extras] -dev = ["coverage", "hypothesis", "hypothesmith (>=0.2)", "pre-commit", "pytest", "tox"] - -[[package]] -name = "flake8-debugger" -version = "4.1.2" -description = "ipdb/pdb statement checker plugin for flake8" -optional = false -python-versions = ">=3.7" -files = [ - {file = "flake8-debugger-4.1.2.tar.gz", hash = "sha256:52b002560941e36d9bf806fca2523dc7fb8560a295d5f1a6e15ac2ded7a73840"}, - {file = "flake8_debugger-4.1.2-py3-none-any.whl", hash = "sha256:0a5e55aeddcc81da631ad9c8c366e7318998f83ff00985a49e6b3ecf61e571bf"}, -] - -[package.dependencies] -flake8 = ">=3.0" -pycodestyle = "*" - -[[package]] -name = "flake8-docstrings" -version = "1.7.0" -description = "Extension for flake8 which uses pydocstyle to check docstrings" -optional = false -python-versions = ">=3.7" -files = [ - {file = "flake8_docstrings-1.7.0-py2.py3-none-any.whl", hash = "sha256:51f2344026da083fc084166a9353f5082b01f72901df422f74b4d953ae88ac75"}, - {file = "flake8_docstrings-1.7.0.tar.gz", hash = "sha256:4c8cc748dc16e6869728699e5d0d685da9a10b0ea718e090b1ba088e67a941af"}, -] - -[package.dependencies] -flake8 = ">=3" -pydocstyle = ">=2.1" - -[[package]] -name = "flake8-isort" -version = "6.0.0" -description = "flake8 plugin that integrates isort ." -optional = false -python-versions = ">=3.7" -files = [ - {file = "flake8-isort-6.0.0.tar.gz", hash = "sha256:537f453a660d7e903f602ecfa36136b140de279df58d02eb1b6a0c84e83c528c"}, - {file = "flake8_isort-6.0.0-py3-none-any.whl", hash = "sha256:aa0cac02a62c7739e370ce6b9c31743edac904bae4b157274511fc8a19c75bbc"}, -] - -[package.dependencies] -flake8 = "*" -isort = ">=5.0.0,<6" - -[package.extras] -test = ["pytest"] - -[[package]] -name = "flake8-string-format" -version = "0.3.0" -description = "string format checker, plugin for flake8" -optional = false -python-versions = "*" -files = [ - {file = "flake8-string-format-0.3.0.tar.gz", hash = "sha256:65f3da786a1461ef77fca3780b314edb2853c377f2e35069723348c8917deaa2"}, - {file = "flake8_string_format-0.3.0-py2.py3-none-any.whl", hash = "sha256:812ff431f10576a74c89be4e85b8e075a705be39bc40c4b4278b5b13e2afa9af"}, -] - -[package.dependencies] -flake8 = "*" - -[[package]] -name = "flake8-tuple" -version = "0.4.1" -description = "Check code for 1 element tuple." -optional = false -python-versions = "*" -files = [ - {file = "flake8_tuple-0.4.1-py2.py3-none-any.whl", hash = "sha256:d828cc8e461c50cacca116e9abb0c9e3be565e8451d3f5c00578c63670aae680"}, - {file = "flake8_tuple-0.4.1.tar.gz", hash = "sha256:8a1b42aab134ef4c3fef13c6a8f383363f158b19fbc165bd91aed9c51851a61d"}, -] - -[package.dependencies] -flake8 = "*" -six = "*" - [[package]] name = "freezegun" version = "1.4.0" @@ -1174,23 +1014,6 @@ files = [ {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, ] -[[package]] -name = "isort" -version = "5.12.0" -description = "A Python utility / library to sort Python imports." -optional = false -python-versions = ">=3.8.0" -files = [ - {file = "isort-5.12.0-py3-none-any.whl", hash = "sha256:f84c2818376e66cf843d497486ea8fed8700b340f308f076c6fb1229dff318b6"}, - {file = "isort-5.12.0.tar.gz", hash = "sha256:8bef7dde241278824a6d83f44a544709b065191b95b6e50894bdc722fcba0504"}, -] - -[package.extras] -colors = ["colorama (>=0.4.3)"] -pipfile-deprecated-finder = ["pip-shims (>=0.5.2)", "pipreqs", "requirementslib"] -plugins = ["setuptools"] -requirements-deprecated-finder = ["pip-api", "pipreqs"] - [[package]] name = "jinja2" version = "3.1.3" @@ -1319,17 +1142,6 @@ files = [ {file = "MarkupSafe-2.1.4.tar.gz", hash = "sha256:3aae9af4cac263007fd6309c64c6ab4506dd2b79382d9d19a1994f9240b8db4f"}, ] -[[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 = "mdurl" version = "0.1.2" @@ -1359,17 +1171,6 @@ pycryptodome = "*" typing-extensions = "*" urllib3 = "*" -[[package]] -name = "mypy-extensions" -version = "1.0.0" -description = "Type system extensions for programs checked with the mypy type checker." -optional = false -python-versions = ">=3.5" -files = [ - {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, - {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, -] - [[package]] name = "nodeenv" version = "1.8.0" @@ -1409,17 +1210,6 @@ files = [ [package.dependencies] regex = ">=2022.3.15" -[[package]] -name = "pathspec" -version = "0.12.1" -description = "Utility library for gitignore style pattern matching of file paths." -optional = false -python-versions = ">=3.8" -files = [ - {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, - {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, -] - [[package]] name = "pdbpp" version = "0.10.3" @@ -1602,17 +1392,6 @@ files = [ {file = "psycopg_binary-3.1.17-cp39-cp39-win_amd64.whl", hash = "sha256:d90c0531e9d591bde8cea04e75107fcddcc56811b638a34853436b23c9a3cb7d"}, ] -[[package]] -name = "pycodestyle" -version = "2.10.0" -description = "Python style guide checker" -optional = false -python-versions = ">=3.6" -files = [ - {file = "pycodestyle-2.10.0-py2.py3-none-any.whl", hash = "sha256:8a4eaf0d0495c7395bdab3589ac2db602797d76207242c17d470186815706610"}, - {file = "pycodestyle-2.10.0.tar.gz", hash = "sha256:347187bdb476329d98f695c213d7295a846d1152ff4fe9bacb8a9590b8ee7053"}, -] - [[package]] name = "pycparser" version = "2.21" @@ -1818,17 +1597,6 @@ snowballstemmer = ">=2.2.0" [package.extras] toml = ["tomli (>=1.2.3)"] -[[package]] -name = "pyflakes" -version = "3.0.1" -description = "passive checker of Python programs" -optional = false -python-versions = ">=3.6" -files = [ - {file = "pyflakes-3.0.1-py2.py3-none-any.whl", hash = "sha256:ec55bf7fe21fff7f1ad2f7da62363d749e2a470500eab1b555334b67aa1ef8cf"}, - {file = "pyflakes-3.0.1.tar.gz", hash = "sha256:ec8b276a6b60bd80defed25add7e439881c19e64850afd9b346283d4165fd0fd"}, -] - [[package]] name = "pygments" version = "2.17.2" @@ -2391,6 +2159,32 @@ pygments = ">=2.13.0,<3.0.0" [package.extras] jupyter = ["ipywidgets (>=7.5.1,<9)"] +[[package]] +name = "ruff" +version = "0.1.15" +description = "An extremely fast Python linter and code formatter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.1.15-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:5fe8d54df166ecc24106db7dd6a68d44852d14eb0729ea4672bb4d96c320b7df"}, + {file = "ruff-0.1.15-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:6f0bfbb53c4b4de117ac4d6ddfd33aa5fc31beeaa21d23c45c6dd249faf9126f"}, + {file = "ruff-0.1.15-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e0d432aec35bfc0d800d4f70eba26e23a352386be3a6cf157083d18f6f5881c8"}, + {file = "ruff-0.1.15-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:9405fa9ac0e97f35aaddf185a1be194a589424b8713e3b97b762336ec79ff807"}, + {file = "ruff-0.1.15-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c66ec24fe36841636e814b8f90f572a8c0cb0e54d8b5c2d0e300d28a0d7bffec"}, + {file = "ruff-0.1.15-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:6f8ad828f01e8dd32cc58bc28375150171d198491fc901f6f98d2a39ba8e3ff5"}, + {file = "ruff-0.1.15-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:86811954eec63e9ea162af0ffa9f8d09088bab51b7438e8b6488b9401863c25e"}, + {file = "ruff-0.1.15-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fd4025ac5e87d9b80e1f300207eb2fd099ff8200fa2320d7dc066a3f4622dc6b"}, + {file = "ruff-0.1.15-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b17b93c02cdb6aeb696effecea1095ac93f3884a49a554a9afa76bb125c114c1"}, + {file = "ruff-0.1.15-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:ddb87643be40f034e97e97f5bc2ef7ce39de20e34608f3f829db727a93fb82c5"}, + {file = "ruff-0.1.15-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:abf4822129ed3a5ce54383d5f0e964e7fef74a41e48eb1dfad404151efc130a2"}, + {file = "ruff-0.1.15-py3-none-musllinux_1_2_i686.whl", hash = "sha256:6c629cf64bacfd136c07c78ac10a54578ec9d1bd2a9d395efbee0935868bf852"}, + {file = "ruff-0.1.15-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:1bab866aafb53da39c2cadfb8e1c4550ac5340bb40300083eb8967ba25481447"}, + {file = "ruff-0.1.15-py3-none-win32.whl", hash = "sha256:2417e1cb6e2068389b07e6fa74c306b2810fe3ee3476d5b8a96616633f40d14f"}, + {file = "ruff-0.1.15-py3-none-win_amd64.whl", hash = "sha256:3837ac73d869efc4182d9036b1405ef4c73d9b1f88da2413875e34e0d6919587"}, + {file = "ruff-0.1.15-py3-none-win_arm64.whl", hash = "sha256:9a933dfb1c14ec7a33cceb1e49ec4a16b51ce3c20fd42663198746efc0427360"}, + {file = "ruff-0.1.15.tar.gz", hash = "sha256:f6dfa8c1b21c913c326919056c390966648b680966febcb796cc9d1aaab8564e"}, +] + [[package]] name = "setuptools" version = "69.0.3" @@ -2656,4 +2450,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.9.13" -content-hash = "d74a7fd336e62c7e8be598541b52cecd2b33aaf0dcad54f6730bb073d08b5b66" +content-hash = "5c4305664f635d6cc7946fc393bbdde9ab9bf53843c4e08b1f3b12eb32ab000d" diff --git a/pyproject.toml b/pyproject.toml index 6d1e00327..0a9afe06a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,19 +46,10 @@ psycopg-binary = "^3.1.17" # Dev dependencies are always pinned to an exact version (No caret or tilde # matching) to ensure everyone uses the same version of the tools, especially # linters & formatters -black = "23.3.0" django-extensions = "3.2.1" factory-boy = "3.2.1" Faker = "20.1.0" -flake8 = "6.0.0" -flake8-bugbear = "23.5.9" -flake8-debugger = "4.1.2" -flake8-docstrings = "1.7.0" -flake8-isort = "6.0.0" -flake8-string-format = "0.3.0" -flake8-tuple = "0.4.1" gitlint = "0.19.1" -isort = "5.12.0" pdbpp = "0.10.3" pre-commit = "3.5.0" pydocstyle = "6.3.0" @@ -75,6 +66,8 @@ python-semantic-release = "8.7.0" requests-mock = "1.10.0" reuse = "1.1.2" syrupy = "4.0.2" +ruff = "^0.1.15" + [tool.isort] skip = ["migrations", "snapshots"] @@ -112,6 +105,46 @@ filterwarnings = [ "ignore:pkg_resources is deprecated as an API:DeprecationWarning", # deprecation in django-simple-history ] +[tool.ruff] +exclude = [ + "migrations", + "snapshots", + ".venv", +] +ignore = [ + "D100", + "D101", + "D102", + "D103", + "D104", + "D105", + "D106", + "D107", + "D202", + "E501", + "D212", # Multi-line docstring summary should start at the first line + "D213", # Multi-line docstring summary should start at the second line + "D407", # Missing dashed underline after section + "D406", # Section name should end with a newline + "D203", # one-blank-line-before-class (docstring) +] +line-length = 88 +select = [ + "C9", + "D", + "E", + "F", + "W", + "I", +] + +[tool.ruff.mccabe] +max-complexity = 11 + +[tool.ruff.lint.isort] +combine-as-imports = true + + [tool.coverage.run] source = ["."] From 99fa84e8eaabe8b9b8e668d8039c006f1750d972 Mon Sep 17 00:00:00 2001 From: David Vogt Date: Wed, 31 Jan 2024 08:53:48 +0100 Subject: [PATCH 2/2] chore: reformat/reword things slightly to make ruff happy --- .../caluma_analytics/management/commands/run_analytics.py | 6 +++++- caluma/caluma_core/tests/test_mutation_params.py | 6 ++---- caluma/caluma_form/api.py | 4 ++-- caluma/caluma_workflow/api.py | 2 +- caluma/caluma_workflow/tests/test_work_item.py | 4 +--- caluma/settings/caluma.py | 5 +++-- caluma/tests/test_schema.py | 4 +--- 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/caluma/caluma_analytics/management/commands/run_analytics.py b/caluma/caluma_analytics/management/commands/run_analytics.py index 4e1df31ba..9f87297fc 100644 --- a/caluma/caluma_analytics/management/commands/run_analytics.py +++ b/caluma/caluma_analytics/management/commands/run_analytics.py @@ -106,7 +106,11 @@ def _rowkey(val): ] ) print(format_string.format(**col_labels)) - print(format_string.format(**{k: "-" * l for k, l in col_lengths.items()})) + print( + format_string.format( + **{col: "-" * length for col, length in col_lengths.items()} + ) + ) for rec in records: fdata = {_rowkey(k): str(v) for k, v in rec.items()} diff --git a/caluma/caluma_core/tests/test_mutation_params.py b/caluma/caluma_core/tests/test_mutation_params.py index 76dfea329..1ecb1fd1a 100644 --- a/caluma/caluma_core/tests/test_mutation_params.py +++ b/caluma/caluma_core/tests/test_mutation_params.py @@ -52,9 +52,7 @@ def check_perm(self, mutation, info): } } } - """ % { - "form": form.slug - } + """ % {"form": form.slug} result = schema_executor(query) assert result.data == { @@ -79,7 +77,7 @@ def check_perm(self, mutation, info): assert len(params) == 1 assert len(params["input"]) == 3 assert params["input"]["slug"] == "email_addr" - assert type(params["input"]["format_validators"]) is list + assert isinstance(params["input"]["format_validators"], list) return True mocker.patch(f"{__name__}._TestPermission.permission_impl", check_perm) diff --git a/caluma/caluma_form/api.py b/caluma/caluma_form/api.py index f437924a2..c0a8255af 100644 --- a/caluma/caluma_form/api.py +++ b/caluma/caluma_form/api.py @@ -10,7 +10,7 @@ def save_answer( user: Optional[BaseUser] = None, value: Optional[Any] = None, context: Optional[dict] = None, - **kwargs + **kwargs, ) -> models.Answer: """ Save an answer for given question, document. @@ -32,7 +32,7 @@ def save_default_answer( question: models.Question, user: Optional[BaseUser] = None, value: Optional[Any] = None, - **kwargs + **kwargs, ) -> models.Answer: """ Save default_answer for given question. diff --git a/caluma/caluma_workflow/api.py b/caluma/caluma_workflow/api.py index fe61d8deb..07dd921b0 100644 --- a/caluma/caluma_workflow/api.py +++ b/caluma/caluma_workflow/api.py @@ -13,7 +13,7 @@ def start_case( form: Optional[Form] = None, parent_work_item: Optional[models.WorkItem] = None, context: Optional[dict] = None, - **kwargs + **kwargs, ) -> models.Case: """ Start a case of a given workflow (just like `saveCase`). diff --git a/caluma/caluma_workflow/tests/test_work_item.py b/caluma/caluma_workflow/tests/test_work_item.py index d8a68d14c..2b8b27817 100644 --- a/caluma/caluma_workflow/tests/test_work_item.py +++ b/caluma/caluma_workflow/tests/test_work_item.py @@ -1062,9 +1062,7 @@ def test_filter_document_has_answer( } } } - """ % { - "filt": filt - } + """ % {"filt": filt} result = schema_executor( query, diff --git a/caluma/settings/caluma.py b/caluma/settings/caluma.py index 564c427b2..af858bb91 100644 --- a/caluma/settings/caluma.py +++ b/caluma/settings/caluma.py @@ -1,7 +1,8 @@ """ -This settings module only contains caluma specific settings. +Caluma specific settings. -It's imported by the main caluma settings and is intended to also be used by third party +This settings module only contains caluma-internal settings. It's imported +by the main caluma settings and is intended to also be used by third party applications integrating Caluma. """ diff --git a/caluma/tests/test_schema.py b/caluma/tests/test_schema.py index 1cb496b61..9bf602282 100644 --- a/caluma/tests/test_schema.py +++ b/caluma/tests/test_schema.py @@ -26,9 +26,7 @@ def test_schema_node(db, snapshot, request, node_type): } } } - """ % { - "name": node_instance.__class__.__name__ - } + """ % {"name": node_instance.__class__.__name__} result = schema.execute(node_query, variable_values={"id": global_id}) assert not result.errors