From 26bcdf73972e29786beeb3d4b1ae38c747a26896 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Fri, 15 Nov 2024 11:16:53 +0100 Subject: [PATCH] Use ruff instead of black, flake8, isort Also, reorder sections in pyproject.toml. Signed-off-by: Nils Philippsen --- duffy/api_models/__init__.py | 10 +- duffy/app/controllers/session.py | 1 + duffy/client/__init__.py | 4 +- duffy/configuration/__init__.py | 2 +- duffy/configuration/validation.py | 6 +- ...1_ignore_failed_nodes_in_unique_indexes.py | 1 + ..._add_node_state_sessionnode_session_id_.py | 1 + ...2e575cb800_add_tenant_session_lifetimes.py | 1 + duffy/database/model/__init__.py | 6 +- duffy/nodes/mechanisms/__init__.py | 4 +- duffy/tasks/__init__.py | 10 +- poetry.lock | 189 +++--------------- pyproject.toml | 29 +-- tests/app/controllers/test_session.py | 4 +- tests/tasks/test_deprovision.py | 4 +- tests/tasks/test_provision.py | 4 +- tests/test_util.py | 2 +- tox.ini | 49 ++--- 18 files changed, 95 insertions(+), 232 deletions(-) diff --git a/duffy/api_models/__init__.py b/duffy/api_models/__init__.py index 238d547b..55b1e74c 100644 --- a/duffy/api_models/__init__.py +++ b/duffy/api_models/__init__.py @@ -1,6 +1,6 @@ -from .common import APIResult, APIResultAction # noqa: F401 -from .node import NodeCreateModel, NodeModel, NodeResult, NodeResultCollection # noqa: F401 -from .pool import ( # noqa: F401 +from .common import APIResult, APIResultAction +from .node import NodeCreateModel, NodeModel, NodeResult, NodeResultCollection +from .pool import ( PoolConciseModel, PoolLevelsModel, PoolModel, @@ -8,7 +8,7 @@ PoolResultCollection, PoolVerboseModel, ) -from .session import ( # noqa: F401 +from .session import ( SessionCreateModel, SessionModel, SessionNodeModel, @@ -16,7 +16,7 @@ SessionResultCollection, SessionUpdateModel, ) -from .tenant import ( # noqa: F401 +from .tenant import ( TenantCreateModel, TenantCreateResult, TenantCreateResultModel, diff --git a/duffy/app/controllers/session.py b/duffy/app/controllers/session.py index f7294b53..642fed3e 100644 --- a/duffy/app/controllers/session.py +++ b/duffy/app/controllers/session.py @@ -1,4 +1,5 @@ """This is the session controller.""" + import datetime as dt import logging from typing import Optional diff --git a/duffy/client/__init__.py b/duffy/client/__init__.py index 33597d0f..e564e18f 100644 --- a/duffy/client/__init__.py +++ b/duffy/client/__init__.py @@ -1,2 +1,2 @@ -from .formatter import DuffyFormatter # noqa: F401 -from .main import DuffyClient # noqa: F401 +from .formatter import DuffyFormatter +from .main import DuffyClient diff --git a/duffy/configuration/__init__.py b/duffy/configuration/__init__.py index fac74622..e940e0ec 100644 --- a/duffy/configuration/__init__.py +++ b/duffy/configuration/__init__.py @@ -1 +1 @@ -from .main import config, config_get, read_configuration # noqa: F401 +from .main import config, config_get, read_configuration diff --git a/duffy/configuration/validation.py b/duffy/configuration/validation.py index e1c99cdd..530a29dd 100644 --- a/duffy/configuration/validation.py +++ b/duffy/configuration/validation.py @@ -84,9 +84,9 @@ class RetriesModel(ConfigBaseModel): delay_backoff_factor: Optional[ Union[Annotated[int, Field(ge=1)], Annotated[float, Field(ge=1)]] ] = Field(alias="delay-backoff-factor", default=None) - delay_add_fuzz: Optional[ - Union[Annotated[int, Field(ge=0)], Annotated[float, Field(ge=0)]] - ] = Field(alias="delay-add-fuzz", default=None) + delay_add_fuzz: Optional[Union[Annotated[int, Field(ge=0)], Annotated[float, Field(ge=0)]]] = ( + Field(alias="delay-add-fuzz", default=None) + ) class DefaultsModel(ConfigBaseModel): diff --git a/duffy/database/migrations/versions/36cf064c0481_ignore_failed_nodes_in_unique_indexes.py b/duffy/database/migrations/versions/36cf064c0481_ignore_failed_nodes_in_unique_indexes.py index 91f45518..ee7a5f82 100644 --- a/duffy/database/migrations/versions/36cf064c0481_ignore_failed_nodes_in_unique_indexes.py +++ b/duffy/database/migrations/versions/36cf064c0481_ignore_failed_nodes_in_unique_indexes.py @@ -4,6 +4,7 @@ Revises: ce2e575cb800 Create Date: 2023-07-27 11:29:37.405520 """ + import sqlalchemy as sa from alembic import op diff --git a/duffy/database/migrations/versions/6654d536b836_add_node_state_sessionnode_session_id_.py b/duffy/database/migrations/versions/6654d536b836_add_node_state_sessionnode_session_id_.py index d0d777b6..7c1bc0b3 100644 --- a/duffy/database/migrations/versions/6654d536b836_add_node_state_sessionnode_session_id_.py +++ b/duffy/database/migrations/versions/6654d536b836_add_node_state_sessionnode_session_id_.py @@ -4,6 +4,7 @@ Revises: 36cf064c0481 Create Date: 2023-09-06 21:42:56.647045 """ + from alembic import op # revision identifiers, used by Alembic. diff --git a/duffy/database/migrations/versions/ce2e575cb800_add_tenant_session_lifetimes.py b/duffy/database/migrations/versions/ce2e575cb800_add_tenant_session_lifetimes.py index 26bc7d2c..5ca02000 100644 --- a/duffy/database/migrations/versions/ce2e575cb800_add_tenant_session_lifetimes.py +++ b/duffy/database/migrations/versions/ce2e575cb800_add_tenant_session_lifetimes.py @@ -4,6 +4,7 @@ Revises: Create Date: 2022-05-09 16:40:06.491392 """ + import sqlalchemy as sa from alembic import op diff --git a/duffy/database/model/__init__.py b/duffy/database/model/__init__.py index 2dc2ee9c..d5953206 100644 --- a/duffy/database/model/__init__.py +++ b/duffy/database/model/__init__.py @@ -1,3 +1,3 @@ -from .node import Node, SessionNode # noqa: F401 -from .session import Session # noqa: F401 -from .tenant import Tenant # noqa: F401 +from .node import Node, SessionNode +from .session import Session +from .tenant import Tenant diff --git a/duffy/nodes/mechanisms/__init__.py b/duffy/nodes/mechanisms/__init__.py index 00240f97..fb04076f 100644 --- a/duffy/nodes/mechanisms/__init__.py +++ b/duffy/nodes/mechanisms/__init__.py @@ -1,2 +1,2 @@ -from . import ansible, main # noqa: F401 -from .main import Mechanism, MechanismFailure # noqa: F401 +from . import ansible, main +from .main import Mechanism, MechanismFailure diff --git a/duffy/tasks/__init__.py b/duffy/tasks/__init__.py index d283f3f3..8821a472 100644 --- a/duffy/tasks/__init__.py +++ b/duffy/tasks/__init__.py @@ -1,5 +1,5 @@ -from .base import celery, init_tasks # noqa: F401 -from .deprovision import deprovision_nodes, deprovision_pool_nodes # noqa: F401 -from .expire import expire_sessions # noqa: F401 -from .main import start_worker # noqa: F401 -from .provision import fill_pools, fill_single_pool # noqa: F401 +from .base import celery, init_tasks +from .deprovision import deprovision_nodes, deprovision_pool_nodes +from .expire import expire_sessions +from .main import start_worker +from .provision import fill_pools, fill_single_pool diff --git a/poetry.lock b/poetry.lock index 8699b479..567fb952 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand. [[package]] name = "aiodns" @@ -353,52 +353,6 @@ files = [ {file = "billiard-4.2.1.tar.gz", hash = "sha256:12b641b0c539073fc8d3f5b8b7be998956665c4233c7c1fcd66a7e677c4fb36f"}, ] -[[package]] -name = "black" -version = "23.12.1" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.8" -files = [ - {file = "black-23.12.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e0aaf6041986767a5e0ce663c7a2f0e9eaf21e6ff87a5f95cbf3675bfd4c41d2"}, - {file = "black-23.12.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c88b3711d12905b74206227109272673edce0cb29f27e1385f33b0163c414bba"}, - {file = "black-23.12.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a920b569dc6b3472513ba6ddea21f440d4b4c699494d2e972a1753cdc25df7b0"}, - {file = "black-23.12.1-cp310-cp310-win_amd64.whl", hash = "sha256:3fa4be75ef2a6b96ea8d92b1587dd8cb3a35c7e3d51f0738ced0781c3aa3a5a3"}, - {file = "black-23.12.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:8d4df77958a622f9b5a4c96edb4b8c0034f8434032ab11077ec6c56ae9f384ba"}, - {file = "black-23.12.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:602cfb1196dc692424c70b6507593a2b29aac0547c1be9a1d1365f0d964c353b"}, - {file = "black-23.12.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9c4352800f14be5b4864016882cdba10755bd50805c95f728011bcb47a4afd59"}, - {file = "black-23.12.1-cp311-cp311-win_amd64.whl", hash = "sha256:0808494f2b2df923ffc5723ed3c7b096bd76341f6213989759287611e9837d50"}, - {file = "black-23.12.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:25e57fd232a6d6ff3f4478a6fd0580838e47c93c83eaf1ccc92d4faf27112c4e"}, - {file = "black-23.12.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2d9e13db441c509a3763a7a3d9a49ccc1b4e974a47be4e08ade2a228876500ec"}, - {file = "black-23.12.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d1bd9c210f8b109b1762ec9fd36592fdd528485aadb3f5849b2740ef17e674e"}, - {file = "black-23.12.1-cp312-cp312-win_amd64.whl", hash = "sha256:ae76c22bde5cbb6bfd211ec343ded2163bba7883c7bc77f6b756a1049436fbb9"}, - {file = "black-23.12.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1fa88a0f74e50e4487477bc0bb900c6781dbddfdfa32691e780bf854c3b4a47f"}, - {file = "black-23.12.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:a4d6a9668e45ad99d2f8ec70d5c8c04ef4f32f648ef39048d010b0689832ec6d"}, - {file = "black-23.12.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b18fb2ae6c4bb63eebe5be6bd869ba2f14fd0259bda7d18a46b764d8fb86298a"}, - {file = "black-23.12.1-cp38-cp38-win_amd64.whl", hash = "sha256:c04b6d9d20e9c13f43eee8ea87d44156b8505ca8a3c878773f68b4e4812a421e"}, - {file = "black-23.12.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3e1b38b3135fd4c025c28c55ddfc236b05af657828a8a6abe5deec419a0b7055"}, - {file = "black-23.12.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4f0031eaa7b921db76decd73636ef3a12c942ed367d8c3841a0739412b260a54"}, - {file = "black-23.12.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:97e56155c6b737854e60a9ab1c598ff2533d57e7506d97af5481141671abf3ea"}, - {file = "black-23.12.1-cp39-cp39-win_amd64.whl", hash = "sha256:dd15245c8b68fe2b6bd0f32c1556509d11bb33aec9b5d0866dd8e2ed3dba09c2"}, - {file = "black-23.12.1-py3-none-any.whl", hash = "sha256:78baad24af0f033958cad29731e27363183e140962595def56423e626f4bee3e"}, - {file = "black-23.12.1.tar.gz", hash = "sha256:4ce3ef14ebe8d9509188014d96af1c456a910d5b5cbf434a09fef7e024b3d0d5"}, -] - -[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 = ">=4.0.1", markers = "python_version < \"3.11\""} - -[package.extras] -colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2)"] - [[package]] name = "build" version = "1.2.2.post1" @@ -1152,22 +1106,6 @@ docs = ["furo (>=2024.8.6)", "sphinx (>=8.0.2)", "sphinx-autodoc-typehints (>=2. testing = ["covdefaults (>=2.3)", "coverage (>=7.6.1)", "diff-cover (>=9.2)", "pytest (>=8.3.3)", "pytest-asyncio (>=0.24)", "pytest-cov (>=5)", "pytest-mock (>=3.14)", "pytest-timeout (>=2.3.1)", "virtualenv (>=20.26.4)"] typing = ["typing-extensions (>=4.12.2)"] -[[package]] -name = "flake8" -version = "5.0.4" -description = "the modular source code checker: pep8 pyflakes and co" -optional = false -python-versions = ">=3.6.1" -files = [ - {file = "flake8-5.0.4-py2.py3-none-any.whl", hash = "sha256:7a1cf6b73744f5806ab95e526f6f0d8c01c66d7bbe349562d22dfca20610b248"}, - {file = "flake8-5.0.4.tar.gz", hash = "sha256:6fbe320aad8d6b95cec8b8e47bc933004678dc63095be98528b7bdd2a9f510db"}, -] - -[package.dependencies] -mccabe = ">=0.7.0,<0.8.0" -pycodestyle = ">=2.9.0,<2.10.0" -pyflakes = ">=2.5.0,<2.6.0" - [[package]] name = "greenlet" version = "3.1.1" @@ -1693,17 +1631,6 @@ files = [ [package.dependencies] traitlets = "*" -[[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 = "mirakuru" version = "2.5.2" @@ -1915,17 +1842,6 @@ files = [ {file = "msgpack-1.1.0.tar.gz", hash = "sha256:dd432ccc2c72b914e4cb77afce64aab761c1137cc698be3984eee260bcb2896e"}, ] -[[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 = "packaging" version = "24.2" @@ -1952,17 +1868,6 @@ files = [ qa = ["flake8 (==5.0.4)", "mypy (==0.971)", "types-setuptools (==67.2.0.1)"] testing = ["docopt", "pytest"] -[[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 = "pexpect" version = "4.9.0" @@ -2300,17 +2205,6 @@ cffi = ">=1.5.0" [package.extras] idna = ["idna (>=2.1)"] -[[package]] -name = "pycodestyle" -version = "2.9.1" -description = "Python style guide checker" -optional = false -python-versions = ">=3.6" -files = [ - {file = "pycodestyle-2.9.1-py2.py3-none-any.whl", hash = "sha256:d1735fc58b418fd7c5f658d28d943854f8a849b01a5d0a1e6f3f3fdd0166804b"}, - {file = "pycodestyle-2.9.1.tar.gz", hash = "sha256:2c9607871d58c76354b697b42f5d57e1ada7d261c261efac224b664affdc5785"}, -] - [[package]] name = "pycparser" version = "2.22" @@ -2446,17 +2340,6 @@ files = [ [package.dependencies] typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0" -[[package]] -name = "pyflakes" -version = "2.5.0" -description = "passive checker of Python programs" -optional = false -python-versions = ">=3.6" -files = [ - {file = "pyflakes-2.5.0-py2.py3-none-any.whl", hash = "sha256:4579f67d887f804e67edb544428f264b7b24f435b263c4614f384135cea553d2"}, - {file = "pyflakes-2.5.0.tar.gz", hash = "sha256:491feb020dca48ccc562a8c0cbe8df07ee13078df59813b83959cbdada312ea3"}, -] - [[package]] name = "pygments" version = "2.18.0" @@ -2541,21 +2424,6 @@ pytest = ">=8.2,<9" docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"] testing = ["coverage (>=6.2)", "hypothesis (>=5.7.1)"] -[[package]] -name = "pytest-black" -version = "0.3.12" -description = "A pytest plugin to enable format checking with black" -optional = false -python-versions = ">=2.7" -files = [ - {file = "pytest-black-0.3.12.tar.gz", hash = "sha256:1d339b004f764d6cd0f06e690f6dd748df3d62e6fe1a692d6a5500ac2c5b75a5"}, -] - -[package.dependencies] -black = {version = "*", markers = "python_version >= \"3.6\""} -pytest = ">=3.5.0" -toml = "*" - [[package]] name = "pytest-cov" version = "5.0.0" @@ -2574,21 +2442,6 @@ pytest = ">=4.6" [package.extras] testing = ["fields", "hunter", "process-tests", "pytest-xdist", "virtualenv"] -[[package]] -name = "pytest-isort" -version = "4.0.0" -description = "py.test plugin to check import ordering using isort" -optional = false -python-versions = ">=3.8,<4" -files = [ - {file = "pytest_isort-4.0.0-py3-none-any.whl", hash = "sha256:14bb3281bab587d6beb53129481e8885232249ec5cfeaf5d903a561ff0589620"}, - {file = "pytest_isort-4.0.0.tar.gz", hash = "sha256:00e99642e282b00b849cf9b49d9102a02ab8c4ec549ace57d7868b723713aaa9"}, -] - -[package.dependencies] -isort = ">=4.0" -pytest = ">=5.0" - [[package]] name = "pytest-postgresql" version = "6.1.1" @@ -2918,6 +2771,33 @@ lint = ["black", "flake8", "isort", "mypy", "types-requests"] release = ["build", "towncrier", "twine"] test = ["commentjson", "packaging", "pytest"] +[[package]] +name = "ruff" +version = "0.7.3" +description = "An extremely fast Python linter and code formatter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.7.3-py3-none-linux_armv6l.whl", hash = "sha256:34f2339dc22687ec7e7002792d1f50712bf84a13d5152e75712ac08be565d344"}, + {file = "ruff-0.7.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:fb397332a1879b9764a3455a0bb1087bda876c2db8aca3a3cbb67b3dbce8cda0"}, + {file = "ruff-0.7.3-py3-none-macosx_11_0_arm64.whl", hash = "sha256:37d0b619546103274e7f62643d14e1adcbccb242efda4e4bdb9544d7764782e9"}, + {file = "ruff-0.7.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5d59f0c3ee4d1a6787614e7135b72e21024875266101142a09a61439cb6e38a5"}, + {file = "ruff-0.7.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:44eb93c2499a169d49fafd07bc62ac89b1bc800b197e50ff4633aed212569299"}, + {file = "ruff-0.7.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6d0242ce53f3a576c35ee32d907475a8d569944c0407f91d207c8af5be5dae4e"}, + {file = "ruff-0.7.3-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:6b6224af8b5e09772c2ecb8dc9f3f344c1aa48201c7f07e7315367f6dd90ac29"}, + {file = "ruff-0.7.3-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c50f95a82b94421c964fae4c27c0242890a20fe67d203d127e84fbb8013855f5"}, + {file = "ruff-0.7.3-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7f3eff9961b5d2644bcf1616c606e93baa2d6b349e8aa8b035f654df252c8c67"}, + {file = "ruff-0.7.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b8963cab06d130c4df2fd52c84e9f10d297826d2e8169ae0c798b6221be1d1d2"}, + {file = "ruff-0.7.3-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:61b46049d6edc0e4317fb14b33bd693245281a3007288b68a3f5b74a22a0746d"}, + {file = "ruff-0.7.3-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:10ebce7696afe4644e8c1a23b3cf8c0f2193a310c18387c06e583ae9ef284de2"}, + {file = "ruff-0.7.3-py3-none-musllinux_1_2_i686.whl", hash = "sha256:3f36d56326b3aef8eeee150b700e519880d1aab92f471eefdef656fd57492aa2"}, + {file = "ruff-0.7.3-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:5d024301109a0007b78d57ab0ba190087b43dce852e552734ebf0b0b85e4fb16"}, + {file = "ruff-0.7.3-py3-none-win32.whl", hash = "sha256:4ba81a5f0c5478aa61674c5a2194de8b02652f17addf8dfc40c8937e6e7d79fc"}, + {file = "ruff-0.7.3-py3-none-win_amd64.whl", hash = "sha256:588a9ff2fecf01025ed065fe28809cd5a53b43505f48b69a1ac7707b1b7e4088"}, + {file = "ruff-0.7.3-py3-none-win_arm64.whl", hash = "sha256:1713e2c5545863cdbfe2cbce21f69ffaf37b813bfd1fb3b90dc9a6f1963f5a8c"}, + {file = "ruff-0.7.3.tar.gz", hash = "sha256:e1d1ba2e40b6e71a61b063354d04be669ab0d39c352461f3d789cac68b54a313"}, +] + [[package]] name = "secretstorage" version = "3.3.3" @@ -3118,17 +2998,6 @@ typing-extensions = {version = ">=3.10.0", markers = "python_version < \"3.10\"" [package.extras] full = ["httpx (>=0.22.0)", "itsdangerous", "jinja2", "python-multipart (>=0.0.7)", "pyyaml"] -[[package]] -name = "toml" -version = "0.10.2" -description = "Python Library for Tom's Obvious, Minimal Language" -optional = false -python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" -files = [ - {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, - {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, -] - [[package]] name = "tomli" version = "2.1.0" @@ -3410,4 +3279,4 @@ tasks = ["Jinja2", "aiodns", "ansible-runner", "celery", "jmespath", "pottery"] [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "e320df2540bd4dc3f6b80d09546ce9d1620e52f1cc57193f98e2d14d8ad03562" +content-hash = "77652bfc358cd4a6149dcad724954181cff7309cdf6388102ac92059025a57eb" diff --git a/pyproject.toml b/pyproject.toml index 59079ae2..b66a6538 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,7 @@ +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" + [tool.poetry] name = "duffy" version = "3.4.0rc2" @@ -64,8 +68,6 @@ Jinja2 = "^3.0.3" ansible = "^5.2 || ^6 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0" ansible-core = "^2.12.1" ansible-runner = "^2.1.1" -black = "^21.9b0 || ^22 || ^23" -flake8 = "^3.9.2 || ^4 || ^5 || ^6.0.0 || ^7.0.0" httpx = "^0.18.2 || ^0.19 || ^0.20 || ^0.21 || ^0.22 || ^0.23 || ^0.24 || ^0.25.0 || ^0.26.0 || ^0.27.0" isort = "^5.9.3" jmespath = "^0.10 || ^1" @@ -73,12 +75,11 @@ poetry = "^1.2.0" pottery = "^3" pytest = ">=6.2.5" pytest-asyncio = "^0.17 || ^0.18 || ^0.19 || ^0.20 || ^0.21 || ^0.23.0 || ^0.24.0" -pytest-black = "^0.3.12" pytest-cov = "^3 || ^4 || ^5.0.0" -pytest-isort = "^2 || ^3 || ^4.0.0" tox = "^3.24.4 || ^4.0.0" psycopg = "^3.0.16" pytest-postgresql = "^4.1.1 || ^5.0.0 || ^6.0.0" +ruff = "^0.7.3" [tool.poetry.extras] # the `serve` command @@ -103,22 +104,22 @@ legacy = ["httpx", "Jinja2"] # the `client ...` commands client = ["httpx"] +[tool.poetry.scripts] +duffy = "duffy.cli:cli" + [tool.pytest.ini_options] addopts = "--black --cov-config .coveragerc --cov=duffy --cov-report term --cov-report xml --cov-report html --isort" asyncio_mode = "auto" asyncio_default_fixture_loop_scope = "function" log_format = "%(levelname)s: %(asctime)s %(short_request_id_optional)s(%(filename)s:%(lineno)s %(message)s)" -[tool.isort] -line_length = 100 -profile = "black" - -[tool.black] +[tool.ruff] line-length = 100 +target-version = "py38" -[build-system] -requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" +[tool.ruff.lint] +select = ["E", "F", "W", "I"] +allowed-confusables = ["’"] -[tool.poetry.scripts] -duffy = "duffy.cli:cli" +[tool.ruff.lint.per-file-ignores] +"**/__init__.py" = ["F401"] diff --git a/tests/app/controllers/test_session.py b/tests/app/controllers/test_session.py index b7ad1b46..01b65504 100644 --- a/tests/app/controllers/test_session.py +++ b/tests/app/controllers/test_session.py @@ -83,9 +83,7 @@ def exception_matches(self, exc): wraps=TweakedSerializationErrorRetryContext, ), mock.patch("duffy.app.controllers.session.set") as mock_set, mock.patch( "duffy.app.controllers.session.sorted" - ) as mock_sorted, caplog.at_level( - "DEBUG" - ): + ) as mock_sorted, caplog.at_level("DEBUG"): self.attrs["nodes_specs"] = [{"pool": "physical-centos8stream-x86_64", "quantity": 1}] def set_side_effect(*args, __aux__=[0], **kwargs): diff --git a/tests/tasks/test_deprovision.py b/tests/tasks/test_deprovision.py index f921cd8e..31dc8e8b 100644 --- a/tests/tasks/test_deprovision.py +++ b/tests/tasks/test_deprovision.py @@ -100,9 +100,7 @@ def test_deprovision_pool_nodes(testcase, test_mechanism, db_sync_session, caplo "duffy.tasks.deprovision.fill_pools" ) as fill_pools, mock.patch( "duffy.tasks.deprovision.decontextualize" - ) as decontextualize, caplog.at_level( - "DEBUG", "duffy" - ): + ) as decontextualize, caplog.at_level("DEBUG", "duffy"): if "mechanism-failure" not in testcase: if not real_playbook: mech_result = {"nodes": [node.data["provision"] for node in nodes]} diff --git a/tests/tasks/test_provision.py b/tests/tasks/test_provision.py index 5ec6d7f6..339c8b6f 100644 --- a/tests/tasks/test_provision.py +++ b/tests/tasks/test_provision.py @@ -152,9 +152,7 @@ def _fake_lookup(node): foo_pool.mechanism, "provision", wraps=wraps_pool_mech_provision ) as pool_mech_provision, mock.patch.object( provision, "_node_lookup_hostname_from_ipaddr", wraps=_fake_lookup - ) as _node_lookup_hostname_from_ipaddr, caplog.at_level( - "DEBUG", "duffy" - ), expectation: + ) as _node_lookup_hostname_from_ipaddr, caplog.at_level("DEBUG", "duffy"), expectation: if "mechanism-failure" in testcase: pool_provision.side_effect = MechanismFailure() elif not real_playbook: diff --git a/tests/test_util.py b/tests/test_util.py index 00c6d355..1ee1fdb2 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -55,7 +55,7 @@ def test___init___with_params(self): delay_backoff_factor=4, delay_add_fuzz=5, ) as retry: - assert retry.exceptions == RuntimeError + assert retry.exceptions is RuntimeError assert retry.no_attempts == 1 assert retry.delay_min == 2 assert retry.delay_max == 3 diff --git a/tox.ini b/tox.ini index 3e8c48ff..f7054bc0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,51 +1,46 @@ [tox] minversion = 3.8.0 envlist = - py{38,39,310,311,312,313} - black - flake8 - isort - poetry + format + lint + poetry + py{38,39,310,311,312,313} isolated_build = true skip_missing_interpreters = true [testenv] +deps = + poetry + pip setenv = - COV_FAIL_UNDER = 100 + COV_FAIL_UNDER = 100 skip_install = true sitepackages = false -whitelist_externals = poetry -commands = - pip install -U pip setuptools poetry +commands_pre = poetry install --all-extras pip install pytest-xdist - duffy --version +commands = pytest -o 'addopts=--cov-config .coveragerc --cov=duffy --cov-report term --cov-report xml --cov-report html -n auto --cov-fail-under {env:COV_FAIL_UNDER}' tests/ [testenv:py39] # Python 3.9 fails tracing an async generator to its completion in create_session() setenv = - COV_FAIL_UNDER = 99 + COV_FAIL_UNDER = 99 -[testenv:black] -commands = - pip -q install black - black --diff duffy/ tests/ +[testenv:format] +deps = ruff +commands_pre = +commands = ruff format --diff duffy/ tests/ -[testenv:flake8] -commands = - pip -q install flake8 - flake8 duffy/ tests/ - -[testenv:isort] -commands = - pip -q install isort - isort --diff duffy/ tests/ +[testenv:lint] +deps = ruff +commands_pre = +commands = ruff check duffy/ tests/ [testenv:poetry] -commands = - pip -q install 'poetry >= 1.6.0' - poetry check --lock +deps = poetry +commands_pre = +commands = poetry check --lock [flake8] max-line-length = 100