Skip to content

Commit 6070687

Browse files
stefanfoulisjuanifioren
authored andcommitted
Enforce consistent formatting using ruff
- replaces flake8 checks with ruff - ruff linting for consistent import sorting - consistent ruff auto-formatting in vscode config (including import sorting) - gh-action: linting and formatting checks using ruff in a separate jobs (for faster feedback)
1 parent 1582ffc commit 6070687

File tree

4 files changed

+37
-9
lines changed

4 files changed

+37
-9
lines changed

.github/workflows/main.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,28 @@ on:
77
branches: ["develop"]
88

99
jobs:
10+
formatting:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: astral-sh/ruff-action@v3
15+
with:
16+
args: "--version"
17+
- run: "ruff format --check --diff"
18+
19+
linting:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: astral-sh/ruff-action@v3
24+
with:
25+
args: "--version"
26+
- run: "ruff check --diff"
27+
1028
tests:
1129
runs-on: ubuntu-latest
1230
steps:
13-
- uses: actions/checkout@v3
31+
- uses: actions/checkout@v4
1432
- uses: actions/setup-python@v4
1533
with:
1634
python-version: |
@@ -25,4 +43,6 @@ jobs:
2543
python -m pip install --upgrade pip
2644
pip install tox
2745
- name: Run tox
28-
run: tox
46+
# we skip the 'ruff' env here, because we are running it in a separate
47+
# parallel job already
48+
run: tox --skip-env ruff

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"[python]": {
33
"editor.formatOnSave": true,
44
"editor.codeActionsOnSave": {
5-
"source.fixAll": "explicit",
6-
"source.organizeImports": "explicit"
5+
"source.fixAll.ruff": "explicit",
6+
"source.organizeImports.ruff": "explicit"
77
},
88
"editor.defaultFormatter": "charliermarsh.ruff"
99
}

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
[tool.ruff]
22
line-length = 100
33

4+
[tool.ruff.lint]
5+
select = [
6+
# Pyflakes
7+
"F",
8+
# isort
9+
"I",
10+
]
11+
412
[tool.ruff.lint.isort]
513
force-single-line = true

tox.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ envlist=
77
py311-django{41,42,50,51},
88
py312-django{41,42,50,51},
99
py313-django{41,42,50,51},
10-
flake8
10+
ruff
1111

1212
[testenv]
1313
changedir=
@@ -23,7 +23,6 @@ deps =
2323
psycopg2-binary
2424
pytest
2525
pytest-django
26-
pytest-flake8
2726
pytest-cov
2827

2928
commands =
@@ -41,12 +40,13 @@ commands =
4140
mkdir -p _static/
4241
sphinx-build -v -W -b html -d {envtmpdir}/doctrees -D html_static_path="_static" . {envtmpdir}/html
4342

44-
[testenv:flake8]
43+
[testenv:ruff]
4544
basepython = python3.11
4645
deps =
47-
flake8
46+
ruff
4847
commands =
49-
flake8 . --exclude=venv/,.tox/,migrations --max-line-length 100
48+
ruff check --diff
49+
ruff format --check --diff
5050

5151
[pytest]
5252
DJANGO_SETTINGS_MODULE = oidc_provider.tests.settings

0 commit comments

Comments
 (0)