From 381af3b806495403b05c3caded03634cd2ec733b Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Thu, 15 Aug 2024 12:31:59 +0800 Subject: [PATCH 1/5] check format using ruff --- .gitignore | 1 + .pre-commit-config.yaml | 7 +++---- pyproject.toml | 15 ++++----------- tox.ini | 3 ++- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 70d81b559..d64e1776b 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ pip-log.txt .coverage .tox .pytest_cache/ +.ruff_cache/ nosetests.xml # Translations diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8a2e65601..1b5e05178 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,9 +1,8 @@ repos: - - repo: https://github.com/psf/black - rev: 24.8.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.5.7 hooks: - - id: black - exclude: ^(oauth2_provider/migrations/|tests/migrations/) + - id: ruff-format - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: diff --git a/pyproject.toml b/pyproject.toml index 884f7aec4..568f7f3de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,17 +1,10 @@ -[tool.black] -line-length = 110 -target-version = ['py38'] -exclude = ''' -^/( - oauth2_provider/migrations/ - | tests/migrations/ - | .tox -) -''' - # Ref: https://github.com/codespell-project/codespell#using-a-config-file [tool.codespell] skip = '.git,package-lock.json,locale,AUTHORS,tox.ini' check-hidden = true ignore-regex = '.*pragma: codespell-ignore.*' ignore-words-list = 'assertIn' + +[tool.ruff] +line-length = 110 +exclude = [".tox", "oauth2_provider/migrations/", "tests/migrations/", "manage.py"] diff --git a/tox.ini b/tox.ini index ba97bd113..48b377240 100644 --- a/tox.ini +++ b/tox.ini @@ -42,6 +42,7 @@ markers = [testenv] commands = + ruff format pytest {posargs} coverage report coverage xml @@ -67,6 +68,7 @@ deps = pytest-xdist pytest-mock requests + ruff>=0.5 passenv = PYTEST_ADDOPTS @@ -106,7 +108,6 @@ deps = flake8 flake8-isort flake8-quotes - flake8-black [testenv:migrations] setenv = From 49073bf902d32b05ed5a40cc67465b168486e0ca Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Thu, 15 Aug 2024 14:22:52 +0800 Subject: [PATCH 2/5] format check only --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 48b377240..f32a5efd1 100644 --- a/tox.ini +++ b/tox.ini @@ -42,7 +42,7 @@ markers = [testenv] commands = - ruff format + ruff format --check pytest {posargs} coverage report coverage xml From 5cdb8acfaffb17eed17ff4e400796b249fc9abde Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Thu, 15 Aug 2024 14:28:48 +0800 Subject: [PATCH 3/5] lint job --- .github/workflows/lint.yaml | 20 ++++++++++++++++++++ tox.ini | 2 -- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/lint.yaml diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 000000000..d6c0567c2 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,20 @@ +name: Test + +on: [push, pull_request] + +jobs: + test-package: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install Ruff + run: | + python -m pip install ruff>=0.5 + - name: Ruff + run: | + ruff format --check diff --git a/tox.ini b/tox.ini index f32a5efd1..44f1fa492 100644 --- a/tox.ini +++ b/tox.ini @@ -42,7 +42,6 @@ markers = [testenv] commands = - ruff format --check pytest {posargs} coverage report coverage xml @@ -68,7 +67,6 @@ deps = pytest-xdist pytest-mock requests - ruff>=0.5 passenv = PYTEST_ADDOPTS From 63b14a5e997f646bb87a776256bb821f8ae2e4b1 Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Thu, 15 Aug 2024 14:29:39 +0800 Subject: [PATCH 4/5] ruff --- .github/workflows/lint.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index d6c0567c2..8ffbd0991 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,10 +1,9 @@ -name: Test +name: Lint on: [push, pull_request] jobs: - test-package: - name: Lint + ruff: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 2b99ac9bca5d36bb79dabf930f30f059c4202428 Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Thu, 15 Aug 2024 14:31:37 +0800 Subject: [PATCH 5/5] descriptive name --- .github/workflows/lint.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 8ffbd0991..fe0637ca4 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -4,6 +4,7 @@ on: [push, pull_request] jobs: ruff: + name: Ruff runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -14,6 +15,6 @@ jobs: - name: Install Ruff run: | python -m pip install ruff>=0.5 - - name: Ruff + - name: Format check (Ruff) run: | ruff format --check