From 380be0296a0045d060e5101f679d16858ebe6c58 Mon Sep 17 00:00:00 2001 From: Matthias Alphart Date: Sun, 5 Nov 2023 10:09:25 +0100 Subject: [PATCH] Use ruff isort plugin instead of isort (#321) --- .pre-commit-config.yaml | 8 ++------ pyproject.toml | 13 +++++-------- requirements_testing.txt | 1 - tox.ini | 9 ++++++--- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4b470f8..a533e0e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,17 +25,13 @@ repos: hooks: - id: flake8 files: ^(xknxproject|examples|docs)/.+\.py$ - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort - args: - - --resolve-all-configs - repo: https://github.com/charliermarsh/ruff-pre-commit # Ruff version. rev: 'v0.0.292' hooks: - id: ruff + # in CI it is directly run by tox to allow dependency upgrade checks + stages: [pre-commit] args: [ --fix, --exit-non-zero-on-fix ] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 diff --git a/pyproject.toml b/pyproject.toml index 5627b63..46f1321 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,17 +35,9 @@ version = {attr = "xknxproject.__version__.__version__"} include = ["xknxproject*"] [tool.black] -target-version = ["py39", "py310", "py311", "py312"] exclude = "generated" -[tool.isort] -profile = "black" -# will group `import x` and `from x import` of the same module. -force_sort_within_sections = true -combine_as_imports = true - - [tool.mypy] python_version = "3.9" strict = true @@ -125,6 +117,7 @@ select = [ "D", # pydocstyle "E", # pycodestyle "F", # pyflakes + "I", # isort "RUF", # ruff specific "T20", # print "UP", # pyupgrade @@ -139,3 +132,7 @@ ignore = [ extend-exclude = [ "script", ] + +[tool.ruff.isort] +force-sort-within-sections = true +combine-as-imports = true diff --git a/requirements_testing.txt b/requirements_testing.txt index a16d548..3ae36b0 100644 --- a/requirements_testing.txt +++ b/requirements_testing.txt @@ -1,6 +1,5 @@ -r requirements_production.txt pre-commit==3.5.0 -isort==5.12.0 flake8==6.1.0 pylint==3.0.2 pytest==7.4.3 diff --git a/tox.ini b/tox.ini index b754f8e..260098c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py39, py310, py311, py312, typing, lint, pylint +envlist = py39, py310, py311, py312, ruff, typing, lint, pylint skip_missing_interpreters = True [testenv] @@ -14,12 +14,10 @@ wheel_build_env = .pkg [testenv:lint] basepython = python3 commands = - ruff check {posargs:.} pre-commit run codespell {posargs: --all-files} pre-commit run flake8 {posargs: --all-files} pre-commit run pyupgrade {posargs: --all-files} pre-commit run black {posargs: --all-files} - pre-commit run isort {posargs: --all-files} pre-commit run check-json {posargs: --all-files} pre-commit run trailing-whitespace {posargs: --all-files} @@ -28,6 +26,11 @@ basepython = python3 commands = pylint xknxproject +[testenv:ruff] +basepython = python3 +commands = + ruff check {posargs:.} + [testenv:typing] basepython = python3 commands =