Skip to content

Commit ff3de33

Browse files
committed
Add linting to the CI setup, using ruff
For now the setup is quite forgiving, but we can toughen it up later.
1 parent 52cac48 commit ff3de33

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

.github/workflows/ruff.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Ruff lint
2+
3+
# Ruff runs on every PR and every push to master.
4+
#
5+
# Two steps:
6+
# * Strict: runs the rule subset for which the codebase is clean today.
7+
# Failures block the workflow, so regressions of these rules cannot be
8+
# merged.
9+
# * Backlog (non-blocking): runs the full configured ruleset (E, F, I) and
10+
# surfaces the existing backlog of cleanups (import sorting, unused imports,
11+
# long lines, etc.). It is marked `continue-on-error: true`; as the backlog
12+
# is cleared the rules can be migrated into the strict step.
13+
14+
on:
15+
pull_request:
16+
branches: [master]
17+
types: [synchronize, opened, reopened, ready_for_review]
18+
push:
19+
branches: [master]
20+
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
ruff-strict:
27+
name: Ruff (strict — real-bug rules)
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
33+
- name: Run ruff (strict subset)
34+
uses: astral-sh/ruff-action@v3
35+
with:
36+
args: "check --select F821,F403,F405 ."
37+
38+
ruff-backlog:
39+
name: Ruff (full ruleset — non-blocking)
40+
runs-on: ubuntu-latest
41+
continue-on-error: true
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@v4
45+
46+
- name: Run ruff (full configured ruleset)
47+
uses: astral-sh/ruff-action@v3
48+
with:
49+
args: "check ."

pyproject.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,14 @@ neo = ["resources/*.json"]
141141

142142
[tool.black]
143143
line-length = 120
144+
145+
[tool.ruff]
146+
line-length = 120
147+
target-version = "py310"
148+
extend-exclude = ["doc/old_stuffs", "doc/build", "dist", "tmp.py"]
149+
150+
[tool.ruff.lint]
151+
select = ["E", "F", "I"]
152+
153+
[tool.ruff.lint.per-file-ignores]
154+
"__init__.py" = ["F401", "F403"]

0 commit comments

Comments
 (0)