Skip to content

Commit 484cf57

Browse files
committed
Development QOL tweaks
1 parent d58d137 commit 484cf57

File tree

11 files changed

+98
-87
lines changed

11 files changed

+98
-87
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-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
3939
<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>
4040
</svg>
41-
""",
41+
""", # noqa: E501
4242
"class": "",
4343
},
4444
],

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 open-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-36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: pyproject.toml

+15-4
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pytest = "*"
8181

8282
[tool.pixi.feature.lint.tasks]
8383
pre-commit-install = { cmd = "pre-commit install" }
84-
pre-commit = { cmd = "pre-commit run -v --all-files --show-diff-on-failure" }
84+
pre-commit = { cmd = "pre-commit run --all-files" }
8585
mypy = { cmd = "mypy", cwd = "." }
8686
pylint = { cmd = ["pylint", "array_api_extra"], cwd = "src" }
8787
pyright = { cmd = "basedpyright", cwd = "." }
@@ -94,9 +94,11 @@ array-api-strict = "*"
9494
numpy = "*"
9595

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

101103
[tool.pixi.feature.docs.dependencies]
102104
sphinx = ">=7.0"
@@ -108,7 +110,7 @@ typing_extensions = ">=4.12.2,<4.13"
108110

109111
[tool.pixi.feature.docs.tasks]
110112
docs = { cmd = ["sphinx-build", ".", "build/"], cwd = "docs" }
111-
open-docs = { cmd = ["open", "build/index.html"], cwd = "docs" }
113+
open-docs = { cmd = ["open", "build/index.html"], cwd = "docs", depends-on = ["docs"] }
112114

113115
[tool.pixi.feature.dev.dependencies]
114116
ipython = "*"
@@ -154,6 +156,7 @@ run.source = ["array_api_extra"]
154156
report.exclude_also = [
155157
'\.\.\.',
156158
'if typing.TYPE_CHECKING:',
159+
'if TYPE_CHECKING:',
157160
]
158161

159162

@@ -200,11 +203,16 @@ target-version = "py310"
200203
[tool.ruff.lint]
201204
extend-select = [
202205
"B", # flake8-bugbear
206+
"F", # Pyflakes
203207
"I", # isort
208+
"E", # Pycodestyle
209+
"W", # Pycodestyle
210+
"N", # pep8-naming
204211
"ARG", # flake8-unused-arguments
205212
"C4", # flake8-comprehensions
206213
"EM", # flake8-errmsg
207214
"ICN", # flake8-import-conventions
215+
"ISC", # flake8-implicit-str-concat
208216
"G", # flake8-logging-format
209217
"PGH", # pygrep-hooks
210218
"PIE", # flake8-pie
@@ -220,11 +228,14 @@ extend-select = [
220228
"EXE", # flake8-executable
221229
"NPY", # NumPy specific rules
222230
"PD", # pandas-vet
231+
"UP", # Pyupgrade
223232
]
224233
ignore = [
225234
"PLR09", # Too many <...>
226235
"PLR2004", # Magic value used in comparison
227236
"ISC001", # Conflicts with formatter
237+
"N802", # Function name should be lowercase
238+
"N806", # Variable in function should be lowercase
228239
]
229240

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

Diff for: src/array_api_extra/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990
1+
from __future__ import annotations
22

33
from ._funcs import atleast_nd, cov, create_diagonal, expand_dims, kron, setdiff1d, sinc
44

Diff for: src/array_api_extra/_funcs.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990
1+
from __future__ import annotations
22

3-
import typing
43
import warnings
54

6-
if typing.TYPE_CHECKING:
7-
from ._lib._typing import Array, ModuleType
8-
95
from ._lib import _utils
106
from ._lib._compat import array_namespace
7+
from ._lib._typing import Array, ModuleType
118

129
__all__ = [
1310
"atleast_nd",

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

+5-17
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
1-
from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990
1+
from __future__ import annotations
22

3-
import typing
43
from types import ModuleType
54
from typing import Any
65

7-
if typing.TYPE_CHECKING:
8-
from typing_extensions import override
6+
# To be changed to a Protocol later (see data-apis/array-api#589)
7+
Array = Any # type: ignore[no-any-explicit]
8+
Device = Any # type: ignore[no-any-explicit]
99

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
19-
20-
__all__ = ["ModuleType", "override"]
21-
if typing.TYPE_CHECKING:
22-
__all__ += ["Array", "Device"]
10+
__all__ = ["Array", "Device", "ModuleType"]

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

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
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
1+
from __future__ import annotations
72

83
from . import _compat
4+
from ._typing import Array, ModuleType
95

106
__all__ = ["in1d", "mean"]
117

Diff for: tests/test_funcs.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990
1+
from __future__ import annotations
22

33
import contextlib
4-
import typing
54
import warnings
65

76
# data-apis/array-api-strict#6
@@ -19,9 +18,7 @@
1918
setdiff1d,
2019
sinc,
2120
)
22-
23-
if typing.TYPE_CHECKING:
24-
from array_api_extra._lib._typing import Array
21+
from array_api_extra._lib._typing import Array
2522

2623

2724
class TestAtLeastND:

Diff for: tests/test_utils.py

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

53
# data-apis/array-api-strict#6
64
import array_api_strict as xp # type: ignore[import-untyped] # pyright: ignore[reportMissingTypeStubs]
75
import pytest
86
from numpy.testing import assert_array_equal
97

8+
from array_api_extra._lib._typing import Array
109
from array_api_extra._lib._utils import in1d
1110

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

1612
# some test coverage already provided by TestSetDiff1D
1713
class TestIn1D:

0 commit comments

Comments
 (0)