Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Ruff lint

# Ruff runs on every PR and every push to master.
#
# Two steps:
# * Strict: runs the rule subset for which the codebase is clean today.
# Failures block the workflow, so regressions of these rules cannot be
# merged.
# * Backlog (non-blocking): runs the full configured ruleset (E, F, I) and
# surfaces the existing backlog of cleanups (import sorting, unused imports,
# long lines, etc.). It is marked `continue-on-error: true`; as the backlog
# is cleared the rules can be migrated into the strict step.

on:
pull_request:
branches: [master]
types: [synchronize, opened, reopened, ready_for_review]
push:
branches: [master]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
ruff-strict:
name: Ruff (strict — real-bug rules)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Run ruff (strict subset)
uses: astral-sh/ruff-action@v3
with:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with:
# Strict subset — only rules the repo already passes, so they can block merges:
# F821 - undefined name (real NameError-class bugs, typos, missing imports)
# F403 - `from module import *` used (hides which names are in scope)
# F405 - name may be undefined, or defined from a star import (F821 that F403 made unprovable)
with:
args: "check --select F821,F403,F405 ."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always forget what those rules mean so I like to document on the spot:

https://github.com/catalystneuro/neuroconv/blob/8d8348f2cbd0cdee74f2eec48d92db469c4c5888/pyproject.toml#L434-L442

Feel free to ignore.

args: "check --select F821,F403,F405 ."

ruff-backlog:
name: Ruff (full ruleset — non-blocking)
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Run ruff (full configured ruleset)
uses: astral-sh/ruff-action@v3
with:
args: "check ."
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,14 @@ neo = ["resources/*.json"]

[tool.black]
line-length = 120

[tool.ruff]
line-length = 120
target-version = "py310"
extend-exclude = ["doc/old_stuffs", "doc/build", "dist", "tmp.py"]

[tool.ruff.lint]
select = ["E", "F", "I"]
Comment on lines +150 to +151
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[tool.ruff.lint]
select = ["E", "F", "I"]
# See https://docs.astral.sh/ruff/rules/
select = [
"E", # pycodestyle errors — style/whitespace (line length, blank lines); large backlog
"F", # Pyflakes — real bugs (undefined names, unused/star imports, redefinitions)
"I", # isort — import sorting and grouping
]


[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401", "F403"]
Loading