Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): add the ruff tool to the pre-commit checks #593

Draft
wants to merge 1 commit into
base: staging
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.286
hooks:
- id: ruff
name: Check ruff issues
args: [--config, pyproject.toml, --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
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ audit:
python -m pip_audit --skip-editable --desc on --fix --dry-run

# Run some or all checks over the package code base.
.PHONY: check check-code check-bandit check-flake8 check-lint check-mypy
check-code: check-bandit check-flake8 check-lint check-mypy check-actionlint
.PHONY: check check-code check-ruff check-bandit check-flake8 check-lint check-mypy
check-code: check-ruff check-bandit check-flake8 check-lint check-mypy check-actionlint
check-ruff:
pre-commit run ruff --all-files
check-bandit:
pre-commit run bandit --all-files
check-flake8:
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]