diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2e8a43dc8..8d588f75f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,17 +1,22 @@ 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: https://github.com/astral-sh/ruff-pre-commit + rev: v0.15.12 + hooks: + - id: ruff-format + - id: ruff-check diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 71d14895c..b36ba4eaf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,14 +19,23 @@ 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. A typical workflow is: ``` 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 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