Skip to content

Commit 865ce11

Browse files
committed
feat(ci): add the ruff tool to the pre-commit checks
1 parent 77bac8b commit 865ce11

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ repos:
5353
files: ^src/package/|^tests/
5454
args: [--py310-plus]
5555

56+
# Ruff is a fast superset of pylint and selection of various flake8 plugins.
57+
- repo: https://github.com/astral-sh/ruff-pre-commit
58+
rev: v0.0.286
59+
hooks:
60+
- id: ruff
61+
name: Check ruff issues
62+
args: [--config, pyproject.toml, --fix, --exit-non-zero-on-fix]
63+
5664
# Similar to pylint, with a few more/different checks. For more available
5765
# extensions: https://github.com/DmytroLitvinov/awesome-flake8-extensions
5866
- repo: https://github.com/pycqa/flake8

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ audit:
150150
python -m pip_audit --skip-editable --desc on --fix --dry-run
151151

152152
# Run some or all checks over the package code base.
153-
.PHONY: check check-code check-bandit check-flake8 check-lint check-mypy
154-
check-code: check-bandit check-flake8 check-lint check-mypy check-actionlint
153+
.PHONY: check check-code check-ruff check-bandit check-flake8 check-lint check-mypy
154+
check-code: check-ruff check-bandit check-flake8 check-lint check-mypy check-actionlint
155+
check-ruff:
156+
pre-commit run ruff --all-files
155157
check-bandit:
156158
pre-commit run bandit --all-files
157159
check-flake8:
@@ -228,7 +230,7 @@ dist-clean:
228230
rm -fr dist/*
229231
rm -f requirements.txt
230232
clean: dist-clean
231-
rm -fr .coverage .hypothesis/ .mypy_cache/ .pytest_cache/
233+
rm -fr .coverage .hypothesis/ .mypy_cache/ .pytest_cache/ .ruff_cache/
232234
rm -fr docs/_build/
233235

234236
# Remove code caches, or the entire virtual environment.

pyproject.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,20 @@ filterwarnings = [
216216
"error::pytest.PytestUnraisableExceptionWarning",
217217
"error::pytest.PytestUnhandledThreadExceptionWarning",
218218
]
219+
220+
221+
# https://beta.ruff.rs/docs/configuration/
222+
# https://beta.ruff.rs/docs/rules/
223+
# https://beta.ruff.rs/docs/settings/
224+
[tool.ruff]
225+
src = ["src/package/", "tests/"]
226+
extend-exclude = ["docs/"]
227+
select = ["B", "B9", "D", "E", "F", "W"]
228+
ignore = ["D105", "E501"]
229+
line-length = 120
230+
target-version = "py310"
231+
232+
[tool.ruff.pydocstyle]
233+
convention = "numpy"
234+
235+
[tool.ruff.per-file-ignores]

0 commit comments

Comments
 (0)