Skip to content

Commit 2bbf7bd

Browse files
committed
DEV: replace pre-commit with lefthook+Pixi
1 parent 7f52342 commit 2bbf7bd

File tree

16 files changed

+2994
-2934
lines changed

16 files changed

+2994
-2934
lines changed

.dprint.jsonc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"json": {
3+
"lineWidth": 100,
4+
"array.preferSingleLine": true,
5+
},
6+
"markdown": {
7+
"lineWidth": 200,
8+
"emphasisKind": "asterisks",
9+
},
10+
"toml": {
11+
"lineWidth": 100,
12+
},
13+
"yaml": {
14+
"printWidth": 100,
15+
"formatComments": true,
16+
// "indentBlockSequenceInMap": false,
17+
"braceSpacing": false,
18+
},
19+
"excludes": ["**/*-lock.json", "**/*.lock", "**/node_modules/", "dist/"],
20+
"plugins": [
21+
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.1.wasm",
22+
"https://plugins.dprint.dev/json-0.20.0.wasm",
23+
"https://plugins.dprint.dev/markdown-0.19.0.wasm",
24+
"https://plugins.dprint.dev/toml-0.7.0.wasm",
25+
],
26+
}

.github/workflows/ci.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ env:
2020
FORCE_COLOR: 3
2121

2222
jobs:
23-
pre-commit-and-lint:
24-
name: Format
23+
lint:
24+
name: Lint
2525
runs-on: ubuntu-latest
2626
steps:
2727
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -30,24 +30,17 @@ jobs:
3030
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
3131
with:
3232
python-version: "3.13.3"
33-
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
34-
with:
35-
extra_args: --hook-stage manual --all-files
3633
- uses: prefix-dev/setup-pixi@19eac09b398e3d0c747adc7921926a6d802df4da # v0.8.8
3734
with:
38-
pixi-version: v0.42.1
35+
pixi-version: v0.49.0
3936
cache: true
4037
environments: lint
41-
- name: Run Pylint, Mypy & Pyright
42-
run: |
43-
pixi run -e lint pylint
44-
pixi run -e lint mypy
45-
pixi run -e lint pyright
38+
- name: Lint
39+
run: pixi run -e lint lint
4640

4741
checks:
4842
name: Test ${{ matrix.environment }}
4943
runs-on: ${{ matrix.runs-on }}
50-
needs: [pre-commit-and-lint]
5144
strategy:
5245
fail-fast: false
5346
matrix:

.pre-commit-config.yaml

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

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@
1616
<!-- SPHINX-START -->
1717

1818
<!-- prettier-ignore-start -->
19-
[actions-badge]: https://github.com/data-apis/array-api-extra/workflows/CI/badge.svg
20-
[actions-link]: https://github.com/data-apis/array-api-extra/actions
21-
[conda-badge]: https://img.shields.io/conda/vn/conda-forge/array-api-extra
22-
[conda-link]: https://github.com/conda-forge/array-api-extra-feedstock
19+
20+
[actions-badge]: https://github.com/data-apis/array-api-extra/workflows/CI/badge.svg
21+
[actions-link]: https://github.com/data-apis/array-api-extra/actions
22+
[conda-badge]: https://img.shields.io/conda/vn/conda-forge/array-api-extra
23+
[conda-link]: https://github.com/conda-forge/array-api-extra-feedstock
2324
[github-discussions-badge]: https://img.shields.io/static/v1?label=Discussions&message=Ask&color=blue&logo=github
24-
[github-discussions-link]: https://github.com/data-apis/array-api-extra/discussions
25-
[pypi-link]: https://pypi.org/project/array-api-extra/
26-
[pypi-platforms]: https://img.shields.io/pypi/pyversions/array-api-extra
27-
[pypi-version]: https://img.shields.io/pypi/v/array-api-extra
28-
[docs-badge]: https://img.shields.io/badge/docs-here!-2ea44f
29-
[docs-link]: https://data-apis.org/array-api-extra/index.html
25+
[github-discussions-link]: https://github.com/data-apis/array-api-extra/discussions
26+
[pypi-link]: https://pypi.org/project/array-api-extra/
27+
[pypi-platforms]: https://img.shields.io/pypi/pyversions/array-api-extra
28+
[pypi-version]: https://img.shields.io/pypi/v/array-api-extra
29+
[docs-badge]: https://img.shields.io/badge/docs-here!-2ea44f
30+
[docs-link]: https://data-apis.org/array-api-extra/index.html
3031

3132
<!-- prettier-ignore-end -->
3233

@@ -38,7 +39,7 @@ Used by:
3839
scientific computing.
3940
- [scikit-learn](https://github.com/scikit-learn/scikit-learn) — Machine
4041
Learning in Python.
41-
- _your library? Let us know!_
42+
- *your library? Let us know!*
4243

4344
## Installation
4445

docs/contributing.md

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ development of array-api-extra is made easy with
6161
at <https://github.com/data-apis/array-api-extra>.
6262
- `cd array-api-extra`.
6363
- [Install Pixi](https://pixi.sh/latest/#installation).
64-
- To enter a development environment:
64+
- To enter a development environment (if you prefer this to the `pixi run` interface):
6565

6666
```
6767
pixi shell -e dev
@@ -73,71 +73,75 @@ pixi shell -e dev
7373
pixi run tests
7474
```
7575

76-
- To generate the coverage report:
76+
- To build the docs locally:
7777

7878
```
79-
pixi run coverage
79+
pixi run docs
8080
```
8181

82-
- To generate and display the coverage report:
82+
- To build and preview the docs locally:
8383

8484
```
85-
pixi run open-coverage
85+
pixi run open-docs
8686
```
8787

88-
- To build the docs locally:
88+
- To install pre-commit hooks:
8989

9090
```
91-
pixi run docs
91+
pixi run hooks
9292
```
9393

94-
- To build and preview the docs locally:
94+
- To run pre-commit checks on staged files:
9595

9696
```
97-
pixi run open-docs
97+
pixi run pre-commit
9898
```
9999

100-
- To install a [pre-commit](https://pre-commit.com) hook:
100+
- To run the full lint suite:
101101

102102
```
103-
pixi run pre-commit-install
103+
pixi run --environment=lint lint
104104
```
105105

106-
- To run the lint suite:
106+
- To enter an interactive Python prompt:
107107

108108
```
109-
pixi run -e lint lint
109+
pixi run ipython
110110
```
111111

112-
- To enter an interactive Python prompt:
112+
- To run individual parts of the lint suite separately (for example):
113113

114114
```
115-
pixi run ipython
115+
pixi run --environment=lint pyright
116+
pixi run --environment=lint dprint
117+
```
118+
119+
- To generate the coverage report:
120+
121+
```
122+
pixi run coverage
116123
```
117124

118-
- To run individual parts of the lint suite separately:
125+
- To generate and display the coverage report:
119126

120127
```
121-
pixi run -e lint pre-commit
122-
pixi run -e lint pylint
123-
pixi run -e lint mypy
124-
pixi run -e lint pyright
128+
pixi run open-coverage
125129
```
126130

127131
Alternative environments are available with a subset of the dependencies and
128132
tasks available in the `dev` environment:
129133

130134
```
131-
pixi shell -e docs
132-
pixi shell -e tests
133-
pixi shell -e tests-backends
134-
pixi shell -e lint
135+
pixi shell --environment=docs
136+
pixi shell --environment=tests
137+
pixi shell --environment=tests-backends
138+
pixi shell --environment=lint
135139
```
136140

137141
If you run on a host with CUDA hardware, you can enable extra tests:
138142

139143
```
140-
pixi shell -e dev-cuda
141-
pixi shell -e tests-cuda
142-
pixi run -e tests-cuda tests
144+
pixi shell --environment=dev-cuda
145+
pixi shell --environment=tests-cuda
146+
pixi run --environment=tests-cuda tests
143147
```

docs/contributors.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
```{include} ../CONTRIBUTORS.md
2-
32
```

docs/index.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ well as delegation to existing implementations for known array library backends.
1717
The intended users of this library are "array-consuming" libraries which are
1818
using [array-api-compat](https://data-apis.org/array-api-compat/) to make their
1919
own library's functions array-agnostic. In this library, they will find a set of
20-
tools which provide _extra_ functionality on top of the array API standard,
20+
tools which provide *extra* functionality on top of the array API standard,
2121
which other array-consuming libraries in a similar position have found useful
2222
themselves.
2323

@@ -27,7 +27,7 @@ It is currently used by:
2727
scientific computing.
2828
- [scikit-learn](https://github.com/scikit-learn/scikit-learn) — Machine
2929
Learning in Python.
30-
- _your library? Let us know!_
30+
- *your library? Let us know!*
3131

3232
(installation)=
3333

@@ -114,8 +114,7 @@ def array_namespace(*xs, **kwargs):
114114
See [an example of this in SciPy][scipy-vendor-example].
115115
```
116116

117-
[scipy-vendor-example]:
118-
https://github.com/scipy/scipy/blob/main/scipy/_lib/_array_api_compat_vendor.py
117+
[scipy-vendor-example]: https://github.com/scipy/scipy/blob/main/scipy/_lib/_array_api_compat_vendor.py
119118

120119
## Versioning
121120

lefthook.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
lefthook: pixi run --environment=lint lefthook
2+
3+
templates:
4+
run: run --environment=lint
5+
6+
pre-commit:
7+
parallel: true
8+
jobs:
9+
- name: dprint
10+
glob: "*.{json,jsonc,md,toml,yaml,yml}"
11+
stage_fixed: true
12+
run: pixi {run} dprint
13+
- name: ruff
14+
glob: "*.{py,pyi}"
15+
stage_fixed: true
16+
group:
17+
piped: true
18+
jobs:
19+
- name: ruff check
20+
run: pixi {run} ruff-check {staged_files}
21+
- name: ruff format
22+
run: pixi {run} ruff-format {staged_files}
23+
- name: pyright
24+
glob: "*.{py,pyi}"
25+
run: pixi {run} pyright {staged_files}
26+
- name: typos
27+
stage_fixed: true
28+
run: pixi {run} typos
29+
- name: actionlint
30+
run: pixi {run} actionlint
31+
- name: blacken-docs
32+
glob: "*.md"
33+
stage_fixed: true
34+
run: pixi {run} blacken-docs {staged_files}
35+
- name: validate-pyproject
36+
glob: "pyproject.toml"
37+
run: pixi {run} validate-pyproject
38+
- name: numpydoc
39+
glob: "*.py"
40+
run: pixi {run} numpydoc {staged_files}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy