From 71f07442e6d18adcfd9d645f55357946c74d4ba5 Mon Sep 17 00:00:00 2001 From: Hanne Moa Date: Fri, 11 Oct 2024 10:01:41 +0200 Subject: [PATCH 1/3] Use ruff instead of flake8 to find syntax errors --- .github/workflows/python.yml | 4 ++-- .pre-commit-config.yaml | 14 +++++++++----- pyproject.toml | 10 +++++++++- tox.ini | 15 +++------------ 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 6ab0d0203..f6affc6f8 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -30,10 +30,10 @@ jobs: - name: Install dependencies run: | pip install -U pip - pip install tox flake8 + pip install tox ruff - name: flake8 critical lint - run: tox -e flake8-critical + run: tox -e ruff-critical test: needs: lint diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ed781ce56..541389f4a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,12 +7,16 @@ repos: - id: end-of-file-fixer exclude: &exclude_pattern '^changelog.d/' - id: debug-statements -- repo: https://github.com/pycqa/flake8 - rev: 7.1.1 +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.9 hooks: - - id: flake8 - name: "Flake8: critical" - args: ['--count', '--select=E9,F63,F7,F82', '--show-source', '--statistics'] + - id: ruff + name: "Ruff: critical" + args: [ + '--select=E9,F63,F7,F82', + '--output-format=full', + '--statistics' + ] types: [file, python] - repo: https://github.com/psf/black rev: 24.8.0 diff --git a/pyproject.toml b/pyproject.toml index 2e948b5ad..bf0aa7deb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,7 @@ dev = [ "black", "coverage", "django-extensions", - "flake8", + "ruff", "ipython", "pre-commit", "python-dotenv", @@ -107,6 +107,14 @@ exclude = ''' ) ''' +[tool.ruff] +line-length = 120 +extend-exclude = [ + ".egg-info", + "migrations", + "templates", +] + [tool.towncrier] directory = "changelog.d" filename = "CHANGELOG.md" diff --git a/tox.ini b/tox.ini index eeafb671b..21e68f05e 100644 --- a/tox.ini +++ b/tox.ini @@ -31,14 +31,14 @@ commands = -coverage combine --append coverage html --include="./src/*" --omit="*/admin.py,*/test*,*/migrations/*" -[testenv:flake8-critical] +[testenv:ruff-critical] setenv = basepython = python3.10 deps = - flake8 + ruff commands = # stop the build if there are Python syntax errors or undefined names - flake8 --count --select=E9,F63,F7,F82 --show-source --statistics src/ + ruff check --output-format=full --select=E9,F63,F7,F82 --statistics src/ [testenv:upgrade-deps] whitelist_externals = cp @@ -95,12 +95,3 @@ omit = exclude_lines = # Ignore not abstract methods, as these cannot be tested raise NotImplementedError - -[flake8] -max-line-length = 88 -filename = - src/**/*.py -extend_exclude = - *.egg-info, - migrations, - templates From 940769f265a720ded8c53df09c5455598e95d57d Mon Sep 17 00:00:00 2001 From: Hanne Moa Date: Fri, 11 Oct 2024 10:13:49 +0200 Subject: [PATCH 2/3] Use python 3.11 for ruff --- .github/workflows/python.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index f6affc6f8..8a7357f6a 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -31,9 +31,13 @@ jobs: run: | pip install -U pip pip install tox ruff + with: + python-version: 3.11 - - name: flake8 critical lint + - name: ruff critical lint run: tox -e ruff-critical + with: + python-version: 3.11 test: needs: lint From f7e2e30d4a048d0b73b3670a87a79ef99c09d92a Mon Sep 17 00:00:00 2001 From: Hanne Moa Date: Mon, 14 Oct 2024 10:04:45 +0200 Subject: [PATCH 3/3] fixup: try making it work --- .github/workflows/python.yml | 4 ---- tox.ini | 1 - 2 files changed, 5 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 8a7357f6a..258bf1309 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -31,13 +31,9 @@ jobs: run: | pip install -U pip pip install tox ruff - with: - python-version: 3.11 - name: ruff critical lint run: tox -e ruff-critical - with: - python-version: 3.11 test: needs: lint diff --git a/tox.ini b/tox.ini index 21e68f05e..2dc4bb456 100644 --- a/tox.ini +++ b/tox.ini @@ -33,7 +33,6 @@ commands = [testenv:ruff-critical] setenv = -basepython = python3.10 deps = ruff commands =