Skip to content

Commit 3b39b09

Browse files
Development QOL tweaks (#61)
Co-authored-by: Lucas Colley <[email protected]>
1 parent d58d137 commit 3b39b09

15 files changed

+92
-107
lines changed

Diff for: .pre-commit-config.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ repos:
1212
additional_dependencies: [black==24.*]
1313

1414
- repo: https://github.com/pre-commit/pre-commit-hooks
15-
rev: "v4.6.0"
15+
rev: "v5.0.0"
1616
hooks:
1717
- id: check-added-large-files
1818
- id: check-case-conflict
@@ -35,14 +35,14 @@ repos:
3535
- id: rst-inline-touching-normal
3636

3737
- repo: https://github.com/rbubley/mirrors-prettier
38-
rev: "v3.3.3"
38+
rev: "v3.4.2"
3939
hooks:
4040
- id: prettier
4141
types_or: [yaml, markdown, html, css, scss, javascript, json]
4242
args: [--prose-wrap=always]
4343

4444
- repo: https://github.com/astral-sh/ruff-pre-commit
45-
rev: "v0.6.1"
45+
rev: "v0.8.2"
4646
hooks:
4747
- id: ruff
4848
args: ["--fix", "--show-fixes"]
@@ -68,13 +68,13 @@ repos:
6868
exclude: .pre-commit-config.yaml
6969

7070
- repo: https://github.com/abravalheri/validate-pyproject
71-
rev: "v0.19"
71+
rev: "v0.23"
7272
hooks:
7373
- id: validate-pyproject
7474
additional_dependencies: ["validate-pyproject-schema-store[all]"]
7575

7676
- repo: https://github.com/python-jsonschema/check-jsonschema
77-
rev: "0.29.1"
77+
rev: "0.30.0"
7878
hooks:
7979
- id: check-dependabot
8080
- id: check-github-workflows

Diff for: docs/conf.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
import importlib.metadata
42
from typing import Any
53

@@ -38,7 +36,7 @@
3836
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
3937
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
4038
</svg>
41-
""",
39+
""", # noqa: E501
4240
"class": "",
4341
},
4442
],

Diff for: docs/contributing.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,25 @@ pixi shell -e dev
4343
pixi run tests
4444
```
4545

46+
- To generate the coverage report:
47+
48+
```
49+
pixi run coverage
50+
```
51+
52+
- To generate and display the coverage report:
53+
54+
```
55+
pixi run open-coverage
56+
```
57+
4658
- To build the docs locally:
4759

4860
```
4961
pixi run docs
5062
```
5163

52-
- To open and preview the locally-built docs:
64+
- To build and preview the docs locally:
5365

5466
```
5567
pixi run open-docs

Diff for: pixi.lock

+50-39
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: pyproject.toml

+15-6
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,14 @@ pre-commit = "*"
7373
pylint = "*"
7474
basedmypy = "*"
7575
basedpyright = "*"
76-
typing_extensions = ">=4.12.2,<4.13"
7776
# import dependencies for mypy:
7877
array-api-strict = "*"
7978
numpy = "*"
8079
pytest = "*"
8180

8281
[tool.pixi.feature.lint.tasks]
8382
pre-commit-install = { cmd = "pre-commit install" }
84-
pre-commit = { cmd = "pre-commit run -v --all-files --show-diff-on-failure" }
83+
pre-commit = { cmd = "pre-commit run --all-files" }
8584
mypy = { cmd = "mypy", cwd = "." }
8685
pylint = { cmd = ["pylint", "array_api_extra"], cwd = "src" }
8786
pyright = { cmd = "basedpyright", cwd = "." }
@@ -94,21 +93,22 @@ array-api-strict = "*"
9493
numpy = "*"
9594

9695
[tool.pixi.feature.tests.tasks]
97-
tests = { cmd = "pytest" }
98-
tests-ci = { cmd = "pytest -ra --cov --cov-report=xml --cov-report=term --durations=20" }
96+
tests = { cmd = "pytest -v" }
97+
tests-ci = { cmd = "pytest -v -ra --cov --cov-report=xml --cov-report=term --durations=20" }
9998
tests-vendor = { cmd = "pytest vendor_tests" }
99+
coverage = { cmd = ["coverage", "html"], depends-on = ["tests-ci"] }
100+
open-coverage = { cmd = ["open", "htmlcov/index.html"], depends-on = ["coverage"] }
100101

101102
[tool.pixi.feature.docs.dependencies]
102103
sphinx = ">=7.0"
103104
furo = ">=2023.08.17"
104105
myst-parser = ">=0.13"
105106
sphinx-copybutton = "*"
106107
sphinx-autodoc-typehints = "*"
107-
typing_extensions = ">=4.12.2,<4.13"
108108

109109
[tool.pixi.feature.docs.tasks]
110110
docs = { cmd = ["sphinx-build", ".", "build/"], cwd = "docs" }
111-
open-docs = { cmd = ["open", "build/index.html"], cwd = "docs" }
111+
open-docs = { cmd = ["open", "build/index.html"], cwd = "docs", depends-on = ["docs"] }
112112

113113
[tool.pixi.feature.dev.dependencies]
114114
ipython = "*"
@@ -154,6 +154,7 @@ run.source = ["array_api_extra"]
154154
report.exclude_also = [
155155
'\.\.\.',
156156
'if typing.TYPE_CHECKING:',
157+
'if TYPE_CHECKING:',
157158
]
158159

159160

@@ -200,11 +201,16 @@ target-version = "py310"
200201
[tool.ruff.lint]
201202
extend-select = [
202203
"B", # flake8-bugbear
204+
"F", # Pyflakes
203205
"I", # isort
206+
"E", # Pycodestyle
207+
"W", # Pycodestyle
208+
"N", # pep8-naming
204209
"ARG", # flake8-unused-arguments
205210
"C4", # flake8-comprehensions
206211
"EM", # flake8-errmsg
207212
"ICN", # flake8-import-conventions
213+
"ISC", # flake8-implicit-str-concat
208214
"G", # flake8-logging-format
209215
"PGH", # pygrep-hooks
210216
"PIE", # flake8-pie
@@ -220,11 +226,14 @@ extend-select = [
220226
"EXE", # flake8-executable
221227
"NPY", # NumPy specific rules
222228
"PD", # pandas-vet
229+
"UP", # Pyupgrade
223230
]
224231
ignore = [
225232
"PLR09", # Too many <...>
226233
"PLR2004", # Magic value used in comparison
227234
"ISC001", # Conflicts with formatter
235+
"N802", # Function name should be lowercase
236+
"N806", # Variable in function should be lowercase
228237
]
229238

230239
[tool.ruff.lint.per-file-ignores]

Diff for: src/array_api_extra/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990
2-
31
from ._funcs import atleast_nd, cov, create_diagonal, expand_dims, kron, setdiff1d, sinc
42

53
__version__ = "0.3.3.dev0"

Diff for: src/array_api_extra/_funcs.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990
2-
3-
import typing
41
import warnings
52

6-
if typing.TYPE_CHECKING:
7-
from ._lib._typing import Array, ModuleType
8-
93
from ._lib import _utils
104
from ._lib._compat import array_namespace
5+
from ._lib._typing import Array, ModuleType
116

127
__all__ = [
138
"atleast_nd",

Diff for: src/array_api_extra/_lib/_compat.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Allow packages that vendor both `array-api-extra` and
22
# `array-api-compat` to override the import location
3-
from __future__ import annotations
43

54
try:
65
from ..._array_api_compat_vendor import ( # pyright: ignore[reportMissingImports]

Diff for: src/array_api_extra/_lib/_typing.py

+4-18
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
1-
from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990
2-
3-
import typing
41
from types import ModuleType
52
from typing import Any
63

7-
if typing.TYPE_CHECKING:
8-
from typing_extensions import override
9-
10-
# To be changed to a Protocol later (see data-apis/array-api#589)
11-
Array = Any # type: ignore[no-any-explicit]
12-
Device = Any # type: ignore[no-any-explicit]
13-
else:
14-
15-
def no_op_decorator(f): # pyright: ignore[reportUnreachable]
16-
return f
17-
18-
override = no_op_decorator
4+
# To be changed to a Protocol later (see data-apis/array-api#589)
5+
Array = Any # type: ignore[no-any-explicit]
6+
Device = Any # type: ignore[no-any-explicit]
197

20-
__all__ = ["ModuleType", "override"]
21-
if typing.TYPE_CHECKING:
22-
__all__ += ["Array", "Device"]
8+
__all__ = ["Array", "Device", "ModuleType"]

Diff for: src/array_api_extra/_lib/_utils.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990
2-
3-
import typing
4-
5-
if typing.TYPE_CHECKING:
6-
from ._typing import Array, ModuleType
7-
81
from . import _compat
2+
from ._typing import Array, ModuleType
93

104
__all__ = ["in1d", "mean"]
115

Diff for: tests/test_funcs.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990
2-
31
import contextlib
4-
import typing
52
import warnings
63

74
# data-apis/array-api-strict#6
@@ -19,9 +16,7 @@
1916
setdiff1d,
2017
sinc,
2118
)
22-
23-
if typing.TYPE_CHECKING:
24-
from array_api_extra._lib._typing import Array
19+
from array_api_extra._lib._typing import Array
2520

2621

2722
class TestAtLeastND:

Diff for: tests/test_utils.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990
2-
3-
import typing
4-
51
# data-apis/array-api-strict#6
62
import array_api_strict as xp # type: ignore[import-untyped] # pyright: ignore[reportMissingTypeStubs]
73
import pytest
84
from numpy.testing import assert_array_equal
95

6+
from array_api_extra._lib._typing import Array
107
from array_api_extra._lib._utils import in1d
118

12-
if typing.TYPE_CHECKING:
13-
from array_api_extra._lib._typing import Array
14-
159

1610
# some test coverage already provided by TestSetDiff1D
1711
class TestIn1D:

Diff for: tests/test_version.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990
2-
31
import importlib.metadata
42

53
import array_api_extra as xpx

Diff for: vendor_tests/_array_api_compat_vendor.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# This file is a hook imported by src/array_api_extra/_lib/_compat.py
2-
from __future__ import annotations
3-
42
from .array_api_compat import * # noqa: F403
53
from .array_api_compat import array_namespace as array_namespace_compat
64

Diff for: vendor_tests/test_vendor.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
import array_api_strict as xp
42
from numpy.testing import assert_array_equal
53

0 commit comments

Comments
 (0)