Skip to content

Commit a783342

Browse files
authored
set up pre-commit hooks (#6)
* configure `pre-commit` hooks * configure `ruff` * autoupdate hook versions
1 parent dbf5b6c commit a783342

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

.pre-commit-config.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-docstring-first
8+
- repo: https://github.com/rbubley/mirrors-prettier
9+
rev: v3.5.3
10+
hooks:
11+
- id: prettier
12+
args: [--cache-location=.prettier_cache/cache]
13+
- repo: https://github.com/ComPWA/taplo-pre-commit
14+
rev: v0.9.3
15+
hooks:
16+
- id: taplo-format
17+
args: [--option, array_auto_collapse=false]
18+
- id: taplo-lint
19+
args: [--no-schema]
20+
- repo: https://github.com/abravalheri/validate-pyproject
21+
rev: v0.24.1
22+
hooks:
23+
- id: validate-pyproject
24+
- repo: https://github.com/astral-sh/ruff-pre-commit
25+
rev: v0.12.0
26+
hooks:
27+
- id: ruff-check
28+
args: [--fix]
29+
- repo: https://github.com/psf/black-pre-commit-mirror
30+
rev: 25.1.0
31+
hooks:
32+
- id: black-jupyter
33+
- repo: https://github.com/keewis/blackdoc
34+
rev: v0.4.0
35+
hooks:
36+
- id: blackdoc
37+
additional_dependencies: ["black==25.1.0"]
38+
- id: blackdoc-autoupdate-black
39+
- repo: https://github.com/kynan/nbstripout
40+
rev: 0.8.1
41+
hooks:
42+
- id: nbstripout
43+
args: [--extra-keys=metadata.kernelspec metadata.langauge_info.version]
44+
45+
ci:
46+
autofix_prs: true
47+
autoupdate_schedule: monthly

pyproject.toml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[tool.ruff]
2+
target-version = "py310"
3+
builtins = ["ellipsis"]
4+
exclude = [
5+
".git",
6+
".eggs",
7+
"build",
8+
"dist",
9+
"__pycache__",
10+
]
11+
line-length = 100
12+
13+
[tool.ruff.lint]
14+
# E402: module level import not at top of file
15+
# E501: line too long - let black worry about that
16+
# E731: do not assign a lambda expression, use a def
17+
ignore = [
18+
"E402",
19+
"E501",
20+
"E731",
21+
]
22+
select = [
23+
"F", # Pyflakes
24+
"E", # Pycodestyle
25+
"I", # isort
26+
"UP", # Pyupgrade
27+
"TID", # flake8-tidy-imports
28+
"W",
29+
]
30+
extend-safe-fixes = [
31+
"TID252", # absolute imports
32+
]
33+
fixable = ["I", "TID252"]
34+
35+
[tool.ruff.lint.isort]
36+
37+
[tool.ruff.lint.flake8-tidy-imports]
38+
# Disallow all relative imports.
39+
ban-relative-imports = "all"

0 commit comments

Comments
 (0)