Skip to content

DEV: pixi run lint improvements #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
strategy:
fail-fast: false
matrix:
environment: [ci-py310, ci-py313, ci-backends]
environment: [tests-py310, tests-py313, tests-backends]
runs-on: [ubuntu-latest]

steps:
Expand Down
19 changes: 14 additions & 5 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pixi run pre-commit-install
- To run the lint suite:

```
pixi run lint
pixi run -e lint lint
```

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

```
pixi run pre-commit
pixi run pylint
pixi run mypy
pixi run pyright
pixi run -e lint pre-commit
pixi run -e lint pylint
pixi run -e lint mypy
pixi run -e lint pyright
```

Alternative environments are available with a subset of the dependencies and
Expand All @@ -130,5 +130,14 @@ tasks available in the `dev` environment:
```
pixi shell -e docs
pixi shell -e tests
pixi shell -e tests-backends
pixi shell -e lint
```

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

```
pixi shell -e dev-cuda
pixi shell -e tests-cuda
pixi run -e tests-cuda tests
```
4,665 changes: 2,237 additions & 2,428 deletions pixi.lock

Large diffs are not rendered by default.

23 changes: 15 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,16 @@ cupy = "*"

[tool.pixi.environments]
default = { solve-group = "default" }
lint = { features = ["lint", "backends"], solve-group = "default" }
lint = { features = ["lint"], solve-group = "default" }
tests = { features = ["tests"], solve-group = "default" }
docs = { features = ["docs"], solve-group = "default" }
dev = { features = ["lint", "tests", "docs", "dev", "backends"], solve-group = "default" }
dev-cuda = { features = ["lint", "tests", "docs", "dev", "backends", "cuda-backends"] }
ci-py310 = ["py310", "tests"]
ci-py313 = ["py313", "tests"]
# CUDA not available on free github actions
ci-backends = ["py310", "tests", "backends"]
tests-backends = ["py310", "tests", "backends", "cuda-backends"]
tests-py310 = ["py310", "tests"]
tests-py313 = ["py313", "tests"]
# CUDA not available on free github actions and on some developers' PCs
tests-backends = ["py310", "tests", "backends"]
tests-cuda = ["py310", "tests", "backends", "cuda-backends"]


# pytest
Expand Down Expand Up @@ -196,6 +196,10 @@ disallow_any_expr = false
# false positives with input validation
disable_error_code = ["redundant-expr", "unreachable"]

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

# pyright

Expand All @@ -208,10 +212,13 @@ typeCheckingMode = "all"
# https://github.com/data-apis/array-api-typing
reportAny = false
reportExplicitAny = false
# no array-api-strict type stubs
# no array-api-strict type stubs; pytest fixtures
reportUnknownMemberType = false
# no array-api-compat type stubs
# no array-api-compat type stubs; pytest fixtures
reportUnknownVariableType = false
# Redundant with mypy checks
reportMissingImports = false
reportMissingTypeStubs = false
# false positives for input validation
reportUnreachable = false

Expand Down
4 changes: 2 additions & 2 deletions src/array_api_extra/_lib/_utils/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# `array-api-compat` to override the import location

try:
from ...._array_api_compat_vendor import ( # pyright: ignore[reportMissingImports]
from ...._array_api_compat_vendor import (
array_namespace,
device,
is_array_api_strict_namespace,
Expand All @@ -18,7 +18,7 @@
size,
)
except ImportError:
from array_api_compat import ( # pyright: ignore[reportMissingTypeStubs]
from array_api_compat import (
array_namespace,
device,
is_array_api_strict_namespace,
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def xp(library: Backend) -> ModuleType: # numpydoc ignore=PR01,RT03
if library == Backend.JAX_NUMPY:
import jax

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

# Possibly wrap module with array_api_compat
return array_namespace(xp.empty(0))
Expand Down
5 changes: 1 addition & 4 deletions tests/test_at.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@

import numpy as np
import pytest
from array_api_compat import ( # type: ignore[import-untyped] # pyright: ignore[reportMissingTypeStubs]
array_namespace,
is_writeable_array,
)

from array_api_extra import at
from array_api_extra._lib import Backend
from array_api_extra._lib._at import _AtOp
from array_api_extra._lib._testing import xp_assert_equal
from array_api_extra._lib._utils._compat import array_namespace, is_writeable_array
from array_api_extra._lib._utils._typing import Array


Expand Down
Loading