Skip to content

Commit e24eff3

Browse files
authored
🔨 more tox, less poe (#431)
2 parents 3ac4dd6 + 75832d8 commit e24eff3

File tree

8 files changed

+180
-419
lines changed

8 files changed

+180
-419
lines changed

.github/workflows/ci.yml

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@ concurrency:
1111
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
1212
cancel-in-progress: true
1313

14+
env:
15+
UV_FROZEN: 1
16+
1417
jobs:
1518
lint:
16-
timeout-minutes: 1
1719
runs-on: ubuntu-latest
20+
timeout-minutes: 2
1821

1922
steps:
2023
- uses: actions/checkout@v4
2124

25+
- uses: scientific-python/repo-review@v0.11.3
26+
with:
27+
plugins: sp-repo-review
28+
2229
- name: markdownlint
2330
uses: DavidAnson/markdownlint-cli2-action@v19
2431
with:
@@ -28,10 +35,21 @@ jobs:
2835
- name: typos
2936
uses: crate-ci/typos@master
3037

38+
- uses: astral-sh/setup-uv@v5
39+
with:
40+
enable-cache: true
41+
python-version: "3.13"
42+
version: latest
43+
44+
- name: ruff
45+
run: |
46+
uv run ruff check --output-format=github
47+
uv run ruff format --check
48+
3149
generate-matrix:
3250
name: Generate Test Matrix
33-
timeout-minutes: 1
3451
runs-on: ubuntu-latest
52+
timeout-minutes: 1
3553

3654
outputs:
3755
matrix: ${{ steps.set-matrix.outputs.matrix }}
@@ -41,10 +59,10 @@ jobs:
4159

4260
- name: Install uv
4361
uses: astral-sh/setup-uv@v5
44-
45-
- name: Install dependencies
46-
run: |
47-
uv sync --locked
62+
with:
63+
enable-cache: true
64+
python-version: "3.13"
65+
version: latest
4866

4967
- name: Generate Matrix
5068
id: set-matrix
@@ -55,8 +73,8 @@ jobs:
5573
5674
typetest:
5775
needs: generate-matrix
58-
timeout-minutes: 3
5976
runs-on: ubuntu-latest
77+
timeout-minutes: 3
6078

6179
strategy:
6280
fail-fast: false
@@ -65,31 +83,32 @@ jobs:
6583
steps:
6684
- uses: actions/checkout@v4
6785

68-
- name: Install uv
86+
- name: setup uv
6987
uses: astral-sh/setup-uv@v5
7088
with:
7189
enable-cache: true
7290
python-version: ${{ matrix.python }}
7391

74-
- name: setup tox
75-
run: uv tool install tox --with tox-uv
76-
77-
- name: Install dependencies
78-
run: |
79-
rm -rf .venv
80-
uv add --no-build-package=numpy "numpy<=${{ matrix.numpy }}"
81-
82-
- name: Run typetest
83-
run: uv run tox -e=typetest
84-
85-
- name: Run stubtest
86-
run: uv run tox -e=stubtest
87-
88-
- name: lint
89-
run: uv run tox -e=lint
92+
- name: basedpyright
93+
run: >
94+
uv run --with="numpy==${{ matrix.numpy }}"
95+
basedpyright
9096
9197
- name: basedmypy
92-
run: uv run tox -e=mypy
93-
94-
- name: basedpyright
95-
run: uv run tox -e=pyright
98+
run: >
99+
uv run --with="numpy==${{ matrix.numpy }}"
100+
mypy
101+
--tb
102+
--hide-error-context
103+
--hide-error-code-links
104+
.
105+
106+
- name: stubtest
107+
run: >
108+
uv run --with="numpy==${{ matrix.numpy }}" --no-editable
109+
stubtest
110+
--tb
111+
--ignore-unused-allowlist
112+
--allowlist=.mypyignore
113+
--mypy-config-file=pyproject.toml
114+
scipy

.pre-commit-config.yaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
ci:
22
autoupdate_branch: "master"
33
autoupdate_commit_msg: "⬆️ update pre-commit hooks"
4-
skip:
5-
- basedpyright
64

75
repos:
86
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -54,6 +52,11 @@ repos:
5452
hooks:
5553
- id: typos
5654

55+
- repo: https://github.com/astral-sh/uv-pre-commit
56+
rev: 0.5.23
57+
hooks:
58+
- id: uv-lock
59+
5760
- repo: https://github.com/astral-sh/ruff-pre-commit
5861
rev: v0.9.2
5962
hooks:
@@ -63,11 +66,3 @@ repos:
6366

6467
- id: ruff-format
6568
types_or: [python, pyi]
66-
67-
- repo: local
68-
hooks:
69-
- id: basedpyright
70-
name: basedpyright
71-
entry: uv run --no-sync --locked basedpyright
72-
language: system
73-
types_or: [python, pyi]

CONTRIBUTING.md

Lines changed: 69 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -192,43 +192,93 @@ uv sync --frozen
192192
### pre-commit
193193

194194
`scipy-stubs` uses [pre-commit](https://pre-commit.com/) to ensure that the code is
195-
formatted and typed correctly when committing the changes.
195+
formatted and typed correctly when committing the changes. For better performance,
196+
you could additionally install [`pre-commit-uv`](https://github.com/tox-dev/pre-commit-uv):
196197

197198
```bash
198-
poe pre-commit
199+
uv tool install pre-commit --with pre-commit-uv --force-reinstall
200+
```
201+
202+
<details>
203+
<summary>Output:</summary>
204+
205+
```plaintext
206+
Resolved 11 packages in 74ms
207+
Prepared 11 packages in 1ms
208+
Uninstalled 11 packages in 9ms
209+
Installed 11 packages in 10ms
210+
~ cfgv==3.4.0
211+
~ distlib==0.3.9
212+
~ filelock==3.17.0
213+
~ identify==2.6.6
214+
~ nodeenv==1.9.1
215+
~ platformdirs==4.3.6
216+
~ pre-commit==4.1.0
217+
~ pre-commit-uv==4.1.4
218+
~ pyyaml==6.0.2
219+
~ uv==0.5.23
220+
~ virtualenv==20.29.1
221+
Installed 1 executable: pre-commit
222+
```
223+
224+
</details>
225+
226+
Now to install the git hook script, make sure that your the root directory of the `scipy-stubs` repo, then run:
227+
228+
```bash
229+
uvx pre-commit install
230+
```
231+
232+
Output:
233+
234+
```plaintext
235+
pre-commit installed at .git/hooks/pre-commit
199236
```
200237

201238
> [!NOTE]
202-
> Pre-commit doesn't run `stubtest`. This will be run by github actions
203-
> when submitting a pull request. See the next section for more details.
239+
> For performance reasons, `pre-commit` won't run `mypy` and `stubtest`. You could do this
240+
> yourself with `tox -e mypy` and `tox -e stubtest`, as explained in the next section.
241+
> That way you won't have to rely on the (slow) github actions workflow when you submit your PR.
204242
205243
### Tox
206244

207245
The pre-commit hooks and `stubtest` can easily be run with [tox](https://github.com/tox-dev/tox).
208246
It can be installed with:
209247

210248
```bash
211-
uv tool install tox --with tox-uv
249+
uv tool install tox --with tox-uv --upgrade
212250
```
213251

214252
To run all environments in parallel, run:
215253

216-
```shell
217-
$ tox -p all
218-
repo-review: OK ✔ in 0.4 seconds
219-
3.12: OK ✔ in 10.38 seconds
220-
3.10: OK ✔ in 10.62 seconds
221-
3.11: OK ✔ in 11.04 seconds
222-
3.13: OK ✔ in 19.42 seconds
223-
repo-review: OK (0.40=setup[0.04]+cmd[0.36] seconds)
224-
pre-commit: OK (24.91=setup[0.04]+cmd[24.87] seconds)
225-
3.10: OK (10.62=setup[0.11]+cmd[10.51] seconds)
226-
3.11: OK (11.04=setup[0.04]+cmd[11.00] seconds)
227-
3.12: OK (10.38=setup[0.04]+cmd[10.34] seconds)
228-
3.13: OK (19.42=setup[0.04]+cmd[19.38] seconds)
229-
congratulations :) (24.96 seconds)
254+
```bash
255+
uvx tox p
230256
```
231257

258+
<details>
259+
<summary>Output:</summary>
260+
261+
```plaintext
262+
lint: OK ✔ in 0.52 seconds
263+
pre-commit: OK ✔ in 2.59 seconds
264+
3.11: OK ✔ in 21.59 seconds
265+
mypy: OK ✔ in 21.62 seconds
266+
pyright: OK ✔ in 25.23 seconds
267+
3.10: OK ✔ in 25.4 seconds
268+
3.12: OK ✔ in 38.71 seconds
269+
pre-commit: OK (2.59=setup[0.03]+cmd[2.56] seconds)
270+
lint: OK (0.52=setup[0.04]+cmd[0.41,0.03,0.05] seconds)
271+
pyright: OK (25.23=setup[0.03]+cmd[25.20] seconds)
272+
mypy: OK (21.62=setup[0.03]+cmd[21.59] seconds)
273+
3.13: OK (53.28=setup[0.03]+cmd[53.25] seconds)
274+
3.12: OK (38.71=setup[0.03]+cmd[38.68] seconds)
275+
3.11: OK (21.59=setup[0.03]+cmd[21.55] seconds)
276+
3.10: OK (25.40=setup[0.03]+cmd[25.36] seconds)
277+
congratulations :) (53.35 seconds)
278+
```
279+
280+
</details>
281+
232282
### Commit message style
233283

234284
See <https://gitmoji.dev/>.

codegen/README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,3 @@ where `$NAME` is the name is the name of the codemod, which can be one of:
1111
- `AnnotateMissing` - Sets the default return type to `None`, and sets the other missing annotations to `scipy._typing.Untyped`.
1212
- `FixTrailingComma` - Adds a trailing comma to parameters that don't fit on one line, so that ruff formats them correctly.
1313
- `PosOnlySelf` - nsures `self` is a positional-only parameter.
14-
15-
> [!NOTE]
16-
> The codemods require `libcst`, which is installable through the **optional** `codegen` dependency group:
17-
>
18-
> ```bash
19-
> poetry install --with=codegen
20-
> ```

0 commit comments

Comments
 (0)