Skip to content

Commit 4143ec0

Browse files
authored
chore: improve pre-commit config and switch to ruff (#313)
* chore: improve pre-commit config and switch to ruff Replaces black/isort/flake8 altogether * Try simpler pytest * link to arch * also link contributing * bump pytest
1 parent 771d357 commit 4143ec0

21 files changed

Lines changed: 531 additions & 456 deletions

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ updates:
66
schedule:
77
interval: "daily"
88
ignore:
9-
# Offical actions have moving tags like v1
9+
# Official actions have moving tags like v1
1010
# that are used, so they don't need updates here
1111
- dependency-name: "actions/*"

.github/workflows/ci.yml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ on:
66
merge_group:
77
push:
88
branches:
9-
- master
10-
- main
11-
- develop
9+
- master
10+
- main
11+
- develop
1212

1313
jobs:
1414
pre-commit:
1515
name: Format
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v4
19-
with:
20-
submodules: recursive
21-
fetch-depth: 0
22-
fetch-tags: true
23-
- uses: actions/setup-python@v3
24-
with:
25-
python-version: 3.12
26-
- uses: pre-commit/action@v3.0.0
27-
with:
28-
extra_args: --hook-stage manual --all-files
18+
- uses: actions/checkout@v4
19+
with:
20+
submodules: recursive
21+
fetch-depth: 0
22+
fetch-tags: true
23+
- uses: actions/setup-python@v3
24+
with:
25+
python-version: 3.12
26+
- uses: pre-commit/action@v3.0.0
27+
with:
28+
extra_args: --hook-stage manual --all-files
2929

3030
checks:
3131
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
@@ -37,21 +37,21 @@ jobs:
3737
runs-on: [ubuntu-latest, macos-latest, windows-latest]
3838

3939
steps:
40-
- uses: actions/checkout@v4
41-
with:
42-
submodules: recursive
43-
fetch-depth: 0
44-
fetch-tags: true
40+
- uses: actions/checkout@v4
41+
with:
42+
submodules: recursive
43+
fetch-depth: 0
44+
fetch-tags: true
4545

46-
- uses: actions/setup-python@v6
47-
with:
48-
python-version: ${{ matrix.python-version }}
46+
- uses: actions/setup-python@v6
47+
with:
48+
python-version: ${{ matrix.python-version }}
4949

50-
- name: Install package
51-
run: python -m pip install . --group test
50+
- name: Install package
51+
run: python -m pip install . --group test
5252

53-
- name: Test package
54-
run: python -m pytest -ra
53+
- name: Test package
54+
run: pytest
5555

5656
checkroot:
5757
name: Check ROOT bindings
@@ -81,7 +81,7 @@ jobs:
8181

8282
- name: Test package
8383
shell: bash -l {0}
84-
run: python -m pytest -ra
84+
run: pytest
8585

8686
pass:
8787
name: All tests passed

.github/workflows/docs.yml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,37 @@ on:
44
workflow_dispatch:
55
push:
66
branches:
7-
- master
8-
- main
7+
- master
8+
- main
99

1010
jobs:
1111
docs:
1212
name: Build and deploy docs
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@v2
17-
with:
18-
submodules: recursive
19-
20-
- uses: actions/setup-python@v2
21-
with:
22-
python-version: 3.12
23-
24-
- name: Install pandoc
25-
uses: r-lib/actions/setup-pandoc@v2
26-
27-
- name: Install package
28-
run: python -m pip install . --group docs
29-
30-
- name: Build documentation
31-
run: |
32-
cd docs
33-
make
34-
touch build/html/.nojekyll
35-
36-
- name: Deploy documentation
37-
uses: peaceiris/actions-gh-pages@v4.0.0
38-
with:
39-
github_token: ${{ secrets.GITHUB_TOKEN }}
40-
publish_dir: ./docs/build/html
16+
- uses: actions/checkout@v2
17+
with:
18+
submodules: recursive
19+
20+
- uses: actions/setup-python@v2
21+
with:
22+
python-version: 3.12
23+
24+
- name: Install pandoc
25+
uses: r-lib/actions/setup-pandoc@v2
26+
27+
- name: Install package
28+
run: python -m pip install . --group docs
29+
30+
- name: Build documentation
31+
run: |
32+
cd docs
33+
make
34+
touch build/html/.nojekyll
35+
36+
- name: Deploy documentation
37+
uses: peaceiris/actions-gh-pages@v4.0.0
38+
with:
39+
github_token: ${{ secrets.GITHUB_TOKEN }}
40+
publish_dir: ./docs/build/html

.github/workflows/wheels.yml

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ jobs:
1515
name: Make SDist
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v4
19-
with:
20-
submodules: recursive
21-
fetch-tags: true
22-
fetch-depth: 0
18+
- uses: actions/checkout@v4
19+
with:
20+
submodules: recursive
21+
fetch-tags: true
22+
fetch-depth: 0
2323

24-
- name: Build SDist
25-
run: pipx run build --sdist
24+
- name: Build SDist
25+
run: pipx run build --sdist
2626

27-
- uses: actions/upload-artifact@v4
28-
with:
29-
name: artifact-sdist
30-
path: dist/*.tar.gz
27+
- uses: actions/upload-artifact@v4
28+
with:
29+
name: artifact-sdist
30+
path: dist/*.tar.gz
3131

3232
build_wheels:
3333
name: Wheel on ${{ matrix.os }} (${{ matrix.arch }})
@@ -42,22 +42,22 @@ jobs:
4242
arch: universal2
4343

4444
steps:
45-
- uses: actions/checkout@v4
46-
with:
47-
submodules: recursive
48-
fetch-tags: true
49-
fetch-depth: 0
45+
- uses: actions/checkout@v4
46+
with:
47+
submodules: recursive
48+
fetch-tags: true
49+
fetch-depth: 0
5050

51-
- uses: pypa/cibuildwheel@v3.3
52-
env:
53-
CIBW_ARCHS: ${{ matrix.arch }}
54-
MACOSX_DEPLOYMENT_TARGET: 11.0
51+
- uses: pypa/cibuildwheel@v3.3
52+
env:
53+
CIBW_ARCHS: ${{ matrix.arch }}
54+
MACOSX_DEPLOYMENT_TARGET: 11.0
5555

56-
- name: Upload wheels
57-
uses: actions/upload-artifact@v4
58-
with:
59-
name: artifact-wheel-${{ matrix.os }}-${{ matrix.arch }}
60-
path: wheelhouse/*.whl
56+
- name: Upload wheels
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: artifact-wheel-${{ matrix.os }}-${{ matrix.arch }}
60+
path: wheelhouse/*.whl
6161

6262
pypi-publish:
6363
needs: [build_wheels, make_sdist]
@@ -67,11 +67,11 @@ jobs:
6767
permissions:
6868
id-token: write
6969
steps:
70-
- uses: actions/download-artifact@v4
71-
with:
72-
path: dist
73-
pattern: artifact-*
74-
merge-multiple: true
70+
- uses: actions/download-artifact@v4
71+
with:
72+
path: dist
73+
pattern: artifact-*
74+
merge-multiple: true
7575

76-
- name: Publish package distributions to PyPI
77-
uses: pypa/gh-action-pypi-publish@release/v1
76+
- name: Publish package distributions to PyPI
77+
uses: pypa/gh-action-pypi-publish@release/v1

.pre-commit-config.yaml

Lines changed: 66 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,67 @@
11
repos:
2-
- repo: https://github.com/psf/black
3-
rev: 25.9.0
4-
hooks:
5-
- id: black
6-
7-
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: v4.1.0
9-
hooks:
10-
- id: check-added-large-files
11-
- id: check-case-conflict
12-
- id: check-merge-conflict
13-
- id: check-symlinks
14-
- id: check-yaml
15-
- id: debug-statements
16-
- id: end-of-file-fixer
17-
- id: mixed-line-ending
18-
- id: requirements-txt-fixer
19-
- id: trailing-whitespace
20-
21-
- repo: https://github.com/PyCQA/isort
22-
rev: 5.12.0
23-
hooks:
24-
- id: isort
25-
26-
- repo: https://github.com/asottile/pyupgrade
27-
rev: v3.21.0
28-
hooks:
29-
- id: pyupgrade
30-
args: ["--py39-plus"]
31-
32-
- repo: https://github.com/pycqa/flake8
33-
rev: 7.0.0
34-
hooks:
35-
- id: flake8
36-
exclude: docs/conf.py
37-
additional_dependencies: [flake8-bugbear, flake8-print]
38-
39-
- repo: https://github.com/pre-commit/mirrors-mypy
40-
rev: v1.17.1
41-
hooks:
42-
- id: mypy
43-
pass_filenames: false # to allow mypy to respect pyproject.toml config
44-
additional_dependencies: [uhi, pydantic, numpy]
2+
- repo: https://github.com/adamchainz/blacken-docs
3+
rev: "1.19.1"
4+
hooks:
5+
- id: blacken-docs
6+
additional_dependencies: [black==24.*]
7+
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: "v5.0.0"
10+
hooks:
11+
- id: check-added-large-files
12+
- id: check-case-conflict
13+
- id: check-merge-conflict
14+
- id: check-symlinks
15+
- id: check-yaml
16+
- id: debug-statements
17+
- id: end-of-file-fixer
18+
- id: mixed-line-ending
19+
- id: name-tests-test
20+
args: ["--pytest-test-first"]
21+
- id: trailing-whitespace
22+
23+
- repo: https://github.com/rbubley/mirrors-prettier
24+
rev: "v3.4.2"
25+
hooks:
26+
- id: prettier
27+
types_or: [yaml, markdown, html, css, scss, javascript, json]
28+
args: [--prose-wrap=always]
29+
exclude: binder/mycorrections.json
30+
31+
- repo: https://github.com/astral-sh/ruff-pre-commit
32+
rev: "v0.9.2"
33+
hooks:
34+
- id: ruff
35+
args: ["--fix", "--show-fixes"]
36+
- id: ruff-format
37+
38+
- repo: https://github.com/codespell-project/codespell
39+
rev: "v2.3.0"
40+
hooks:
41+
- id: codespell
42+
43+
- repo: https://github.com/abravalheri/validate-pyproject
44+
rev: "v0.23"
45+
hooks:
46+
- id: validate-pyproject
47+
additional_dependencies: ["validate-pyproject-schema-store[all]"]
48+
49+
- repo: https://github.com/python-jsonschema/check-jsonschema
50+
rev: "0.31.0"
51+
hooks:
52+
- id: check-dependabot
53+
- id: check-github-workflows
54+
- id: check-readthedocs
55+
56+
- repo: https://github.com/asottile/pyupgrade
57+
rev: v3.21.0
58+
hooks:
59+
- id: pyupgrade
60+
args: ["--py39-plus"]
61+
62+
- repo: https://github.com/pre-commit/mirrors-mypy
63+
rev: v1.17.1
64+
hooks:
65+
- id: mypy
66+
pass_filenames: false # to allow mypy to respect pyproject.toml config
67+
additional_dependencies: [uhi, pydantic, numpy]

.readthedocs.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)