Skip to content

Commit 6211326

Browse files
authored
Merge pull request #1613 from maykinmedia/add-ruff-to-ci
Add ruff to ci
2 parents 1309c42 + 6bf4df1 commit 6211326

File tree

9 files changed

+99
-8
lines changed

9 files changed

+99
-8
lines changed

.git-blame-ignore-revs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# format YAML files (remove whitespace)
22

33
7ba06e990ff66aadb422e3dba3edbbbcb9bdf970
4+
5+
# Apply ruff fixes for E + F
6+
39b04db835afdc2086ff433b0a2694ccd254dd74

.github/workflows/code-quality.yml

+17-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ jobs:
9494
ports:
9595
- 5432:5432
9696
# Needed because the postgres container does not provide a healthcheck
97-
options:
98-
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
97+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
9998

10099
steps:
101100
- uses: actions/checkout@v3
@@ -135,6 +134,22 @@ jobs:
135134
- name: Run Prettier
136135
run: |
137136
npm run check-linting
137+
138+
ruff:
139+
name: Lint code with ruff
140+
runs-on: ubuntu-latest
141+
142+
steps:
143+
- uses: actions/checkout@v4
144+
- name: Install Python
145+
uses: actions/setup-python@v5
146+
with:
147+
python-version: '3.11'
148+
- name: Install dependencies
149+
run: grep ^ruff requirements/ci.txt | pip install -r /dev/stdin
150+
- name: Run ruff on all files
151+
run: ruff check -e --output-format=github src
152+
138153
bandit:
139154
name: Python security check using Bandit
140155
runs-on: ubuntu-latest

requirements/ci.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,8 @@ ruamel-yaml-clib==0.2.12
10041004
# -c requirements/base.txt
10051005
# -r requirements/base.txt
10061006
# ruamel-yaml
1007+
ruff==0.9.6
1008+
# via -r requirements/test-tools.in
10071009
sentry-sdk[django]==2.19.2
10081010
# via
10091011
# -c requirements/base.txt

requirements/dev.txt

+4
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,10 @@ ruamel-yaml-clib==0.2.12
11581158
# -c requirements/ci.txt
11591159
# -r requirements/ci.txt
11601160
# ruamel-yaml
1161+
ruff==0.9.6
1162+
# via
1163+
# -c requirements/ci.txt
1164+
# -r requirements/ci.txt
11611165
sentry-sdk[django]==2.19.2
11621166
# via
11631167
# -c requirements/ci.txt

requirements/test-tools.in

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ black
1818
isort
1919
flake8
2020
autoflake
21+
ruff
2122

2223
# DigidLocal
2324
pyopenssl

ruff.toml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Exclude a variety of commonly ignored directories.
2+
exclude = [
3+
".bzr",
4+
".direnv",
5+
".eggs",
6+
".git",
7+
".git-rewrite",
8+
".hg",
9+
".ipynb_checkpoints",
10+
".mypy_cache",
11+
".nox",
12+
".pants.d",
13+
".pyenv",
14+
".pytest_cache",
15+
".pytype",
16+
".ruff_cache",
17+
".svn",
18+
".tox",
19+
".venv",
20+
".vscode",
21+
"__pypackages__",
22+
"_build",
23+
"buck-out",
24+
"build",
25+
"dist",
26+
"node_modules",
27+
"site-packages",
28+
"venv",
29+
"env",
30+
]
31+
32+
# Same as Black.
33+
line-length = 88
34+
indent-width = 4
35+
36+
# Assume Python 3.11
37+
target-version = "py311"
38+
39+
[lint]
40+
select = [
41+
# https://docs.astral.sh/ruff/rules/#error-e
42+
"E",
43+
# https://docs.astral.sh/ruff/rules/#pyflakes-f
44+
"F",
45+
]
46+
ignore = [
47+
# Whitespace before ':' (conflicts with Black)
48+
"E203",
49+
# Two spaces before inline comment
50+
"E261",
51+
# Line too long
52+
"E501",
53+
# Do not assign a lambda expression
54+
"E731",
55+
# Name may be undefined from '*' import
56+
"F405",
57+
# Local variable is assigned but never used
58+
"F841",
59+
# Ambiguous variable name
60+
"E741",
61+
]
62+
63+
64+
# Allow fix for all enabled rules (when `--fix`) is provided.
65+
fixable = ["ALL"]
66+
unfixable = []
67+
68+
# Allow unused variables when underscore-prefixed.
69+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

src/open_inwoner/accounts/apps.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@ class AccountsConfig(AppConfig):
6565
_has_run = False
6666

6767
def ready(self):
68-
from .signals import ( # noqa:register the signals
69-
log_user_login,
70-
log_user_logout,
71-
)
68+
# Register the signals upon app init
69+
from .signals import log_user_login, log_user_logout # noqa:F401
7270

7371
if self._has_run:
7472
return

src/open_inwoner/conf/local_example.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
PLAYWRIGHT_MULTI_ONLY_DEFAULT = True
1818

1919
# Enable django-debug-toolbar
20-
from .dev import INSTALLED_APPS, MIDDLEWARE
20+
from .dev import INSTALLED_APPS, MIDDLEWARE # noqa: E402
2121

2222
INSTALLED_APPS += ["debug_toolbar"]
2323
MIDDLEWARE += ["debug_toolbar.middleware.DebugToolbarMiddleware"]

src/openklant2/tests/test_partij.py

-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ def test_create_persoon(client) -> None:
9393
"digitaleAdressen": None,
9494
"rekeningnummers": None,
9595
"voorkeursRekeningnummer": None,
96-
"soortPartij": "persoon",
9796
"voorkeurstaal": "nld",
9897
"indicatieActief": True,
9998
"indicatieGeheimhouding": False,

0 commit comments

Comments
 (0)