Skip to content

Development QOL tweaks #61

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
Dec 12, 2024
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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
additional_dependencies: [black==24.*]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.6.0"
rev: "v5.0.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -35,14 +35,14 @@ repos:
- id: rst-inline-touching-normal

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

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.6.1"
rev: "v0.8.2"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand All @@ -68,13 +68,13 @@ repos:
exclude: .pre-commit-config.yaml

- repo: https://github.com/abravalheri/validate-pyproject
rev: "v0.19"
rev: "v0.23"
hooks:
- id: validate-pyproject
additional_dependencies: ["validate-pyproject-schema-store[all]"]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.29.1"
rev: "0.30.0"
hooks:
- id: check-dependabot
- id: check-github-workflows
4 changes: 1 addition & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import importlib.metadata
from typing import Any

Expand Down Expand Up @@ -38,7 +36,7 @@
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
<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>
</svg>
""",
""", # noqa: E501
"class": "",
},
],
Expand Down
14 changes: 13 additions & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,25 @@ pixi shell -e dev
pixi run tests
```

- To generate the coverage report:

```
pixi run coverage
```

- To generate and display the coverage report:

```
pixi run open-coverage
```

- To build the docs locally:

```
pixi run docs
```

- To open and preview the locally-built docs:
- To build and preview the docs locally:

```
pixi run open-docs
Expand Down
89 changes: 50 additions & 39 deletions pixi.lock

Large diffs are not rendered by default.

21 changes: 15 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,14 @@ pre-commit = "*"
pylint = "*"
basedmypy = "*"
basedpyright = "*"
typing_extensions = ">=4.12.2,<4.13"
# import dependencies for mypy:
array-api-strict = "*"
numpy = "*"
pytest = "*"

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

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

[tool.pixi.feature.docs.dependencies]
sphinx = ">=7.0"
furo = ">=2023.08.17"
myst-parser = ">=0.13"
sphinx-copybutton = "*"
sphinx-autodoc-typehints = "*"
typing_extensions = ">=4.12.2,<4.13"

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

[tool.pixi.feature.dev.dependencies]
ipython = "*"
Expand Down Expand Up @@ -154,6 +154,7 @@ run.source = ["array_api_extra"]
report.exclude_also = [
'\.\.\.',
'if typing.TYPE_CHECKING:',
'if TYPE_CHECKING:',
]


Expand Down Expand Up @@ -200,11 +201,16 @@ target-version = "py310"
[tool.ruff.lint]
extend-select = [
"B", # flake8-bugbear
"F", # Pyflakes
"I", # isort
"E", # Pycodestyle
"W", # Pycodestyle
"N", # pep8-naming
"ARG", # flake8-unused-arguments
"C4", # flake8-comprehensions
"EM", # flake8-errmsg
"ICN", # flake8-import-conventions
"ISC", # flake8-implicit-str-concat
"G", # flake8-logging-format
"PGH", # pygrep-hooks
"PIE", # flake8-pie
Expand All @@ -220,11 +226,14 @@ extend-select = [
"EXE", # flake8-executable
"NPY", # NumPy specific rules
"PD", # pandas-vet
"UP", # Pyupgrade
]
ignore = [
"PLR09", # Too many <...>
"PLR2004", # Magic value used in comparison
"ISC001", # Conflicts with formatter
"N802", # Function name should be lowercase
"N806", # Variable in function should be lowercase
]

[tool.ruff.lint.per-file-ignores]
Expand Down
2 changes: 0 additions & 2 deletions src/array_api_extra/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990

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

__version__ = "0.3.3.dev0"
Expand Down
7 changes: 1 addition & 6 deletions src/array_api_extra/_funcs.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990

import typing
import warnings

if typing.TYPE_CHECKING:
from ._lib._typing import Array, ModuleType

from ._lib import _utils
from ._lib._compat import array_namespace
from ._lib._typing import Array, ModuleType

__all__ = [
"atleast_nd",
Expand Down
1 change: 0 additions & 1 deletion src/array_api_extra/_lib/_compat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Allow packages that vendor both `array-api-extra` and
# `array-api-compat` to override the import location
from __future__ import annotations

try:
from ..._array_api_compat_vendor import ( # pyright: ignore[reportMissingImports]
Expand Down
22 changes: 4 additions & 18 deletions src/array_api_extra/_lib/_typing.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990

import typing
from types import ModuleType
from typing import Any

if typing.TYPE_CHECKING:
from typing_extensions import override

# To be changed to a Protocol later (see data-apis/array-api#589)
Array = Any # type: ignore[no-any-explicit]
Device = Any # type: ignore[no-any-explicit]
else:

def no_op_decorator(f): # pyright: ignore[reportUnreachable]
return f

override = no_op_decorator
# To be changed to a Protocol later (see data-apis/array-api#589)
Array = Any # type: ignore[no-any-explicit]
Device = Any # type: ignore[no-any-explicit]

__all__ = ["ModuleType", "override"]
if typing.TYPE_CHECKING:
__all__ += ["Array", "Device"]
__all__ = ["Array", "Device", "ModuleType"]
8 changes: 1 addition & 7 deletions src/array_api_extra/_lib/_utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990

import typing

if typing.TYPE_CHECKING:
from ._typing import Array, ModuleType

from . import _compat
from ._typing import Array, ModuleType

__all__ = ["in1d", "mean"]

Expand Down
7 changes: 1 addition & 6 deletions tests/test_funcs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990

import contextlib
import typing
import warnings

# data-apis/array-api-strict#6
Expand All @@ -19,9 +16,7 @@
setdiff1d,
sinc,
)

if typing.TYPE_CHECKING:
from array_api_extra._lib._typing import Array
from array_api_extra._lib._typing import Array


class TestAtLeastND:
Expand Down
8 changes: 1 addition & 7 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990

import typing

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

from array_api_extra._lib._typing import Array
from array_api_extra._lib._utils import in1d

if typing.TYPE_CHECKING:
from array_api_extra._lib._typing import Array


# some test coverage already provided by TestSetDiff1D
class TestIn1D:
Expand Down
2 changes: 0 additions & 2 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations # https://github.com/pylint-dev/pylint/pull/9990

import importlib.metadata

import array_api_extra as xpx
Expand Down
2 changes: 0 additions & 2 deletions vendor_tests/_array_api_compat_vendor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# This file is a hook imported by src/array_api_extra/_lib/_compat.py
from __future__ import annotations

from .array_api_compat import * # noqa: F403
from .array_api_compat import array_namespace as array_namespace_compat

Expand Down
2 changes: 0 additions & 2 deletions vendor_tests/test_vendor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import array_api_strict as xp
from numpy.testing import assert_array_equal

Expand Down
Loading