Skip to content

Commit

Permalink
feat(ci): add the ruff tool to the pre-commit checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jenstroeger committed Aug 2, 2023
1 parent 77bac8b commit 3a52f2b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ repos:
files: ^src/package/|^tests/
args: [--py310-plus]

# Ruff is a fast superset of pylint and selection of various flake8 plugins.
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.282
hooks:
- id: ruff
name: Ruff code
args: [--fix, --exit-non-zero-on-fix]

# Similar to pylint, with a few more/different checks. For more available
# extensions: https://github.com/DmytroLitvinov/awesome-flake8-extensions
- repo: https://github.com/pycqa/flake8
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ check-mypy:
pre-commit run mypy --all-files
check-actionlint:
pre-commit run actionlint --all-files
check-ruff:
pre-commit run ruff --all-files
check:
pre-commit run --all-files

Expand Down Expand Up @@ -228,7 +230,7 @@ dist-clean:
rm -fr dist/*
rm -f requirements.txt
clean: dist-clean
rm -fr .coverage .hypothesis/ .mypy_cache/ .pytest_cache/
rm -fr .coverage .hypothesis/ .mypy_cache/ .pytest_cache/ .ruff_cache/
rm -fr docs/_build/

# Remove code caches, or the entire virtual environment.
Expand Down
17 changes: 17 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,20 @@ filterwarnings = [
"error::pytest.PytestUnraisableExceptionWarning",
"error::pytest.PytestUnhandledThreadExceptionWarning",
]


# https://beta.ruff.rs/docs/configuration/
# https://beta.ruff.rs/docs/rules/
# https://beta.ruff.rs/docs/settings/
[tool.ruff]
src = ["src/package/", "tests/"]
extend-exclude = ["docs/"]
select = ["B", "B9", "D", "E", "F", "W"]
ignore = ["D105", "E501"]
line-length = 120
target-version = "py310"

[tool.ruff.pydocstyle]
convention = "numpy"

[tool.ruff.per-file-ignores]

0 comments on commit 3a52f2b

Please sign in to comment.