Skip to content

Commit 88a0496

Browse files
committed
Add pre-commit config with ruff and pre-commit-hooks
Based on pytest-dev conventions (pytest-cov). Hooks: - ruff-check with --fix for linting (E, F, I, W, UP) - ruff-format for formatting - trailing-whitespace, end-of-file-fixer, check-yaml tests/fixtures/ excluded from ruff entirely (intentional undefined names, deprecated methods, etc).
1 parent 7bbf857 commit 88a0496

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

.pre-commit-config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.15.9
4+
hooks:
5+
- id: ruff-check
6+
args: [--fix]
7+
- id: ruff-format
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: v6.0.0
10+
hooks:
11+
- id: trailing-whitespace
12+
- id: end-of-file-fixer
13+
- id: check-yaml

pyproject.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,15 @@ push-changes = false
5151
tag-format = "v{version}"
5252
tag-message = "unittest2pytest {version}"
5353
tag-signing = true
54+
55+
[tool.ruff]
56+
target-version = "py39"
57+
extend-exclude = ["tests/fixtures"]
58+
59+
[tool.ruff.lint]
60+
select = ["E", "F", "I", "W", "UP"]
61+
ignore = ["E501", "E701", "E741", "UP031"]
62+
63+
[tool.ruff.lint.per-file-ignores]
64+
"unittest2pytest/fixes/fix_remove_class.py" = ["W291"]
65+
"unittest2pytest/fixes/fix_self_assert.py" = ["F841"]

0 commit comments

Comments
 (0)