Skip to content

Commit 39f6a27

Browse files
authored
DEV: pixi run lint improvements (#104)
1 parent 45b64d2 commit 39f6a27

File tree

7 files changed

+2272
-2449
lines changed

7 files changed

+2272
-2449
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
strategy:
4949
fail-fast: false
5050
matrix:
51-
environment: [ci-py310, ci-py313, ci-backends]
51+
environment: [tests-py310, tests-py313, tests-backends]
5252
runs-on: [ubuntu-latest]
5353

5454
steps:

docs/contributing.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pixi run pre-commit-install
106106
- To run the lint suite:
107107

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

112112
- To enter an interactive Python prompt:
@@ -118,10 +118,10 @@ pixi run ipython
118118
- To run individual parts of the lint suite separately:
119119

120120
```
121-
pixi run pre-commit
122-
pixi run pylint
123-
pixi run mypy
124-
pixi run pyright
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
125125
```
126126

127127
Alternative environments are available with a subset of the dependencies and
@@ -130,5 +130,14 @@ tasks available in the `dev` environment:
130130
```
131131
pixi shell -e docs
132132
pixi shell -e tests
133+
pixi shell -e tests-backends
133134
pixi shell -e lint
134135
```
136+
137+
If you run on a host with CUDA hardware, you can enable extra tests:
138+
139+
```
140+
pixi shell -e dev-cuda
141+
pixi shell -e tests-cuda
142+
pixi run -e tests-cuda tests
143+
```

pixi.lock

Lines changed: 2237 additions & 2428 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,16 @@ cupy = "*"
152152

153153
[tool.pixi.environments]
154154
default = { solve-group = "default" }
155-
lint = { features = ["lint", "backends"], solve-group = "default" }
155+
lint = { features = ["lint"], solve-group = "default" }
156156
tests = { features = ["tests"], solve-group = "default" }
157157
docs = { features = ["docs"], solve-group = "default" }
158158
dev = { features = ["lint", "tests", "docs", "dev", "backends"], solve-group = "default" }
159159
dev-cuda = { features = ["lint", "tests", "docs", "dev", "backends", "cuda-backends"] }
160-
ci-py310 = ["py310", "tests"]
161-
ci-py313 = ["py313", "tests"]
162-
# CUDA not available on free github actions
163-
ci-backends = ["py310", "tests", "backends"]
164-
tests-backends = ["py310", "tests", "backends", "cuda-backends"]
160+
tests-py310 = ["py310", "tests"]
161+
tests-py313 = ["py313", "tests"]
162+
# CUDA not available on free github actions and on some developers' PCs
163+
tests-backends = ["py310", "tests", "backends"]
164+
tests-cuda = ["py310", "tests", "backends", "cuda-backends"]
165165

166166

167167
# pytest
@@ -196,6 +196,10 @@ disallow_any_expr = false
196196
# false positives with input validation
197197
disable_error_code = ["redundant-expr", "unreachable"]
198198

199+
[[tool.mypy.overrides]]
200+
# slow/unavailable on Windows; do not add to the lint env
201+
module = ["dask.*", "jax.*"]
202+
ignore_missing_imports = true
199203

200204
# pyright
201205

@@ -208,10 +212,13 @@ typeCheckingMode = "all"
208212
# https://github.com/data-apis/array-api-typing
209213
reportAny = false
210214
reportExplicitAny = false
211-
# no array-api-strict type stubs
215+
# no array-api-strict type stubs; pytest fixtures
212216
reportUnknownMemberType = false
213-
# no array-api-compat type stubs
217+
# no array-api-compat type stubs; pytest fixtures
214218
reportUnknownVariableType = false
219+
# Redundant with mypy checks
220+
reportMissingImports = false
221+
reportMissingTypeStubs = false
215222
# false positives for input validation
216223
reportUnreachable = false
217224

src/array_api_extra/_lib/_utils/_compat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# `array-api-compat` to override the import location
44

55
try:
6-
from ...._array_api_compat_vendor import ( # pyright: ignore[reportMissingImports]
6+
from ...._array_api_compat_vendor import (
77
array_namespace,
88
device,
99
is_array_api_strict_namespace,
@@ -18,7 +18,7 @@
1818
size,
1919
)
2020
except ImportError:
21-
from array_api_compat import ( # pyright: ignore[reportMissingTypeStubs]
21+
from array_api_compat import (
2222
array_namespace,
2323
device,
2424
is_array_api_strict_namespace,

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ def xp(library: Backend) -> ModuleType: # numpydoc ignore=PR01,RT03
107107
if library == Backend.JAX_NUMPY:
108108
import jax
109109

110-
jax.config.update("jax_enable_x64", True) # type: ignore[no-untyped-call]
110+
# suppress unused-ignore to run mypy in -e lint as well as -e dev
111+
jax.config.update("jax_enable_x64", True) # type: ignore[no-untyped-call,unused-ignore]
111112

112113
# Possibly wrap module with array_api_compat
113114
return array_namespace(xp.empty(0))

tests/test_at.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@
55

66
import numpy as np
77
import pytest
8-
from array_api_compat import ( # type: ignore[import-untyped] # pyright: ignore[reportMissingTypeStubs]
9-
array_namespace,
10-
is_writeable_array,
11-
)
128

139
from array_api_extra import at
1410
from array_api_extra._lib import Backend
1511
from array_api_extra._lib._at import _AtOp
1612
from array_api_extra._lib._testing import xp_assert_equal
13+
from array_api_extra._lib._utils._compat import array_namespace, is_writeable_array
1714
from array_api_extra._lib._utils._typing import Array
1815

1916

0 commit comments

Comments
 (0)