Skip to content

Commit 3a52f2b

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

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
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.282
59+
hooks:
60+
- id: ruff
61+
name: Ruff code
62+
args: [--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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ check-mypy:
162162
pre-commit run mypy --all-files
163163
check-actionlint:
164164
pre-commit run actionlint --all-files
165+
check-ruff:
166+
pre-commit run ruff --all-files
165167
check:
166168
pre-commit run --all-files
167169

@@ -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)