From dd1471d6b518ed325ae2c5b21c890fcfd3e2dc07 Mon Sep 17 00:00:00 2001 From: layday Date: Fri, 20 Jan 2023 00:50:03 +0200 Subject: [PATCH 1/5] infra: replace flake8 with ruff As a first step, this ports all of our existing flake8 rules to Ruff. I have omitted pyupgrade for which Ruff has partial support. --- .pre-commit-config.yaml | 9 ++++----- pyproject.toml | 16 ++++++++++++++++ .../packages/test-bad-wheel/backend_bad_wheel.py | 2 +- .../test-no-prepare/backend_no_prepare.py | 3 ++- tests/test_integration.py | 2 +- tests/test_util.py | 2 +- tox.ini | 6 ------ 7 files changed, 25 insertions(+), 15 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2e4d0bc9..60fbe725 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,12 +43,11 @@ repos: rev: 5.11.4 hooks: - id: isort - - repo: https://github.com/PyCQA/flake8 - rev: "6.0.0" + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.226 hooks: - - id: flake8 - additional_dependencies: ["flake8-bugbear==22.7.1"] - language_version: python3.9 + - id: ruff + args: [--force-exclude, --format, grouped, --show-source] - repo: https://github.com/codespell-project/codespell rev: "v2.2.2" hooks: diff --git a/pyproject.toml b/pyproject.toml index d2f5491f..5822fd3b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -142,3 +142,19 @@ lines_after_imports = 2 line_length = 127 known_first_party = "build" skip = [] # "build" is included in the default skip list + +[tool.ruff] +line-length = 127 +target-version = "py37" +select = [ + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "C9", # mccabe + "E", # pycodestyle + "F", # pyflakes + "W", # pycodestyle + "RUF", # ruff +] + +[tool.ruff.mccabe] +max-complexity = 10 diff --git a/tests/packages/test-bad-wheel/backend_bad_wheel.py b/tests/packages/test-bad-wheel/backend_bad_wheel.py index 039cae0b..60bd7020 100644 --- a/tests/packages/test-bad-wheel/backend_bad_wheel.py +++ b/tests/packages/test-bad-wheel/backend_bad_wheel.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: MIT -from setuptools.build_meta import build_sdist # noqa: F401 +from setuptools.build_meta import build_sdist as build_sdist def build_wheel(wheel_directory, config_settings=None, metadata_directory=None): diff --git a/tests/packages/test-no-prepare/backend_no_prepare.py b/tests/packages/test-no-prepare/backend_no_prepare.py index 206de1ad..a10da510 100644 --- a/tests/packages/test-no-prepare/backend_no_prepare.py +++ b/tests/packages/test-no-prepare/backend_no_prepare.py @@ -1,3 +1,4 @@ # SPDX-License-Identifier: MIT -from setuptools.build_meta import build_sdist, build_wheel # noqa: F401 +from setuptools.build_meta import build_sdist as build_sdist +from setuptools.build_meta import build_wheel as build_wheel diff --git a/tests/test_integration.py b/tests/test_integration.py index 5da35ad3..13238c82 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -124,7 +124,7 @@ def test_build(monkeypatch, project, args, call, tmp_path): def test_isolation(tmp_dir, package_test_flit, mocker): try: - import flit_core # noqa: F401 + import flit_core # noqa: F401 # imported but unused except ModuleNotFoundError: pass else: diff --git a/tests/test_util.py b/tests/test_util.py index 9f090b57..faf831f6 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -17,7 +17,7 @@ def test_wheel_metadata(package_test_setuptools, isolated): @pytest.mark.pypy3323bug def test_wheel_metadata_isolation(package_test_flit): try: - import flit_core # noqa: F401 + import flit_core # noqa: F401 # imported but unused except ModuleNotFoundError: pass else: diff --git a/tox.ini b/tox.ini index 40ad1efd..e7b51cc6 100644 --- a/tox.ini +++ b/tox.ini @@ -101,9 +101,3 @@ commands = coverage html -d {toxworkdir}/htmlcov -i python -m diff_cover.diff_cover_tool --compare-branch {env:DIFF_AGAINST:origin/main} {toxworkdir}/coverage.xml depends = {py311, py310, py39, py38, py37, pypy37, pypy38, pypy39}{,-min}, path - -[flake8] -max-line-length = 127 -max-complexity = 10 -extend-ignore = E203 -extend-select = B9 From 3523ae30b2a80e4fb8383be5cab3f2adf03b8113 Mon Sep 17 00:00:00 2001 From: layday Date: Fri, 20 Jan 2023 18:49:45 +0200 Subject: [PATCH 2/5] fixup! infra: replace flake8 with ruff --- .pre-commit-config.yaml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 60fbe725..85e918c0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -47,7 +47,7 @@ repos: rev: v0.0.226 hooks: - id: ruff - args: [--force-exclude, --format, grouped, --show-source] + args: [--force-exclude, --format, grouped] - repo: https://github.com/codespell-project/codespell rev: "v2.2.2" hooks: diff --git a/pyproject.toml b/pyproject.toml index 5822fd3b..3d5be97e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -153,7 +153,7 @@ select = [ "E", # pycodestyle "F", # pyflakes "W", # pycodestyle - "RUF", # ruff + "RUF100", # ruff ] [tool.ruff.mccabe] From 48a4981757cca2bb7bb3704e0116f2594fe00513 Mon Sep 17 00:00:00 2001 From: layday Date: Fri, 20 Jan 2023 22:40:00 +0200 Subject: [PATCH 3/5] fixup! infra: replace flake8 with ruff --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 85e918c0..5f804a6a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -47,7 +47,7 @@ repos: rev: v0.0.226 hooks: - id: ruff - args: [--force-exclude, --format, grouped] + args: [--fix, --format, grouped] - repo: https://github.com/codespell-project/codespell rev: "v2.2.2" hooks: From 41d5b9d777418eace8953ea153ea922ee7afb364 Mon Sep 17 00:00:00 2001 From: layday Date: Fri, 20 Jan 2023 22:40:47 +0200 Subject: [PATCH 4/5] fixup! infra: replace flake8 with ruff --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5f804a6a..ded76547 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -44,7 +44,7 @@ repos: hooks: - id: isort - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.226 + rev: v0.0.227 hooks: - id: ruff args: [--fix, --format, grouped] From 9b7d21840de96a3c48fc6fb77af9876fadc75f17 Mon Sep 17 00:00:00 2001 From: layday Date: Fri, 20 Jan 2023 22:41:51 +0200 Subject: [PATCH 5/5] fixup! infra: replace flake8 with ruff --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ded76547..64a9c4fe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -44,7 +44,7 @@ repos: hooks: - id: isort - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.227 + rev: v0.0.228 hooks: - id: ruff args: [--fix, --format, grouped]