From ad0276fdac6a74553b4eab5b5d89b8fd754e1cf2 Mon Sep 17 00:00:00 2001 From: gabrielfruet Date: Wed, 13 May 2026 11:47:24 +0200 Subject: [PATCH 1/2] chore: add ruff pre-commit checks --- .pre-commit-config.yaml | 46 +++++++++++++++++++++++++++-------------- CONTRIBUTING.md | 4 +++- Makefile | 8 ++----- 3 files changed, 35 insertions(+), 23 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2e8a43dc8..8820821ce 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,17 +1,31 @@ repos: - - repo: https://github.com/kynan/nbstripout.git - rev: 0.9.0 - hooks: - - id: nbstripout - description: "Strips outputs from Jupyter notebooks." - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v6.0.0 - hooks: - - id: check-added-large-files - description: "Avoid committing large files." - args: ["--maxkb=2000", "--enforce-all"] - - repo: https://github.com/fastai/nbdev - rev: 3.0.14 - hooks: - - id: nbdev-clean - args: [--fname=examples] \ No newline at end of file + - repo: https://github.com/kynan/nbstripout.git + rev: 0.9.0 + hooks: + - id: nbstripout + description: "Strips outputs from Jupyter notebooks." + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: check-added-large-files + description: "Avoid committing large files." + args: ["--maxkb=2000", "--enforce-all"] + - repo: https://github.com/fastai/nbdev + rev: 3.0.14 + hooks: + - id: nbdev-clean + args: [--fname=examples] + - repo: local + hooks: + - id: ruff-format-check + name: ruff format (check) + entry: ruff format --check + language: system + types_or: [python] + description: "Ensure Python files are formatted with Ruff." + - id: ruff-check + name: ruff check + entry: ruff check + language: system + types_or: [python] + description: "Run Ruff lint checks." diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 71d14895c..d51f193f5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,9 +19,11 @@ Make sure the environment is activated before running the following commands. ### Running Checks and Tests -Before committing code, make sure all tests and checks pass: +Before committing code, make sure the checks pass. The common file-level checks are +handled by pre-commit, which `make install-dev` installs for you: ``` +pre-commit run --all-files make format make static-checks ``` diff --git a/Makefile b/Makefile index 5a9303956..9729e54de 100644 --- a/Makefile +++ b/Makefile @@ -58,16 +58,12 @@ format: add-header # run format check .PHONY: format-check format-check: - # Check code formatting - ruff format --check . - # Check linting issues - ruff check . + # Run pre-commit hooks + pre-commit run --all-files # Check markdown formatting mdformat --check ${MDFORMAT_FILES} # Check code in markdown files pytest docs/format_code.py::test_format_check_code_in_docs - # Run pre-commit hooks - pre-commit run --all-files # run type check .PHONY: type-check From a5468fdf3660e1af31a7bea909dc7abb111db08d Mon Sep 17 00:00:00 2001 From: gabrielfruet Date: Wed, 13 May 2026 13:10:37 +0200 Subject: [PATCH 2/2] chore: pin Ruff pre-commit hooks --- .pre-commit-config.yaml | 15 +++------------ CONTRIBUTING.md | 15 +++++++++++---- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8820821ce..8d588f75f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,17 +15,8 @@ repos: hooks: - id: nbdev-clean args: [--fname=examples] - - repo: local + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.15.12 hooks: - - id: ruff-format-check - name: ruff format (check) - entry: ruff format --check - language: system - types_or: [python] - description: "Ensure Python files are formatted with Ruff." + - id: ruff-format - id: ruff-check - name: ruff check - entry: ruff check - language: system - types_or: [python] - description: "Run Ruff lint checks." diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d51f193f5..b36ba4eaf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,16 +19,23 @@ Make sure the environment is activated before running the following commands. ### Running Checks and Tests -Before committing code, make sure the checks pass. The common file-level checks are -handled by pre-commit, which `make install-dev` installs for you: +Before committing code, make sure the checks pass. A typical workflow is: ``` -pre-commit run --all-files make format make static-checks ``` -and if you want to run all the tests: +`make format` fixes formatting and lint issues, and `make static-checks` validates +formatting, linting, markdown formatting, and type checking. + +If you only want the hook-based file checks, run: + +``` +pre-commit run --all-files +``` + +To run all the tests: ``` make test