Skip to content

Commit d772c0a

Browse files
authored
Merge pull request #170 from crusaderky/py39
MAINT: drop Python 3.9 informal support
2 parents 3db7f75 + ca0c1d2 commit d772c0a

File tree

7 files changed

+17
-36
lines changed

7 files changed

+17
-36
lines changed

pixi.lock

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

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ typing-extensions = "*"
111111
numpy = "*"
112112

113113
[tool.pixi.feature.docs.tasks]
114-
docs = { cmd = "sphinx-build . build/", cwd = "docs" }
114+
docs = { cmd = "sphinx-build -E -W . build/", cwd = "docs" }
115115
open-docs = { cmd = "open build/index.html", cwd = "docs", depends-on = ["docs"] }
116116

117117
[tool.pixi.feature.dev.dependencies]

src/array_api_extra/_lib/_at.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
"""Update operations for read-only arrays."""
22

3-
# https://github.com/scikit-learn/scikit-learn/pull/27910#issuecomment-2568023972
43
from __future__ import annotations
54

65
import operator
76
from collections.abc import Callable
87
from enum import Enum
98
from types import ModuleType
10-
from typing import ClassVar, cast
9+
from typing import TYPE_CHECKING, ClassVar, cast
1110

1211
from ._utils._compat import (
1312
array_namespace,
@@ -18,6 +17,10 @@
1817
from ._utils._helpers import meta_namespace
1918
from ._utils._typing import Array, SetIndex
2019

20+
if TYPE_CHECKING: # pragma: no cover
21+
# TODO import from typing (requires Python >=3.11)
22+
from typing_extensions import Self
23+
2124

2225
class _AtOp(Enum):
2326
"""Operations for use in `xpx.at`."""
@@ -204,7 +207,7 @@ def __init__(
204207
self._x = x
205208
self._idx = idx
206209

207-
def __getitem__(self, idx: SetIndex, /) -> at: # numpydoc ignore=PR01,RT01
210+
def __getitem__(self, idx: SetIndex, /) -> Self: # numpydoc ignore=PR01,RT01
208211
"""
209212
Allow for the alternate syntax ``at(x)[start:stop:step]``.
210213
@@ -214,7 +217,7 @@ def __getitem__(self, idx: SetIndex, /) -> at: # numpydoc ignore=PR01,RT01
214217
if self._idx is not _undef:
215218
msg = "Index has already been set"
216219
raise ValueError(msg)
217-
return at(self._x, idx)
220+
return type(self)(self._x, idx)
218221

219222
def _op(
220223
self,

src/array_api_extra/_lib/_funcs.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
"""Array-agnostic implementations for the public API."""
22

3-
# https://github.com/scikit-learn/scikit-learn/pull/27910#issuecomment-2568023972
4-
from __future__ import annotations
5-
63
import math
74
import warnings
85
from collections.abc import Callable, Sequence

src/array_api_extra/_lib/_lazy.py

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
"""Public API Functions."""
22

3-
# https://github.com/scikit-learn/scikit-learn/pull/27910#issuecomment-2568023972
43
from __future__ import annotations
54

65
import math
76
from collections.abc import Callable, Sequence
87
from functools import partial, wraps
98
from types import ModuleType
10-
from typing import TYPE_CHECKING, Any, cast, overload
9+
from typing import TYPE_CHECKING, Any, ParamSpec, TypeAlias, cast, overload
1110

1211
from ._funcs import broadcast_shapes
1312
from ._utils import _compat
@@ -20,23 +19,15 @@
2019
from ._utils._typing import Array, DType
2120

2221
if TYPE_CHECKING: # pragma: no cover
23-
# TODO move outside TYPE_CHECKING
24-
# depends on scikit-learn abandoning Python 3.9
25-
# https://github.com/scikit-learn/scikit-learn/pull/27910#issuecomment-2568023972
26-
from typing import ParamSpec, TypeAlias
27-
2822
import numpy as np
2923
from numpy.typing import ArrayLike
3024

3125
NumPyObject: TypeAlias = np.ndarray[Any, Any] | np.generic # type: ignore[explicit-any]
32-
P = ParamSpec("P")
3326
else:
34-
# Sphinx hacks
27+
# Sphinx hack
3528
NumPyObject = Any
3629

37-
class P: # pylint: disable=missing-class-docstring
38-
args: tuple
39-
kwargs: dict
30+
P = ParamSpec("P")
4031

4132

4233
@overload

src/array_api_extra/_lib/_utils/_helpers.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Helper functions used by `array_api_extra/_funcs.py`."""
22

3-
# https://github.com/scikit-learn/scikit-learn/pull/27910#issuecomment-2568023972
43
from __future__ import annotations
54

65
import math

src/array_api_extra/testing.py

+5-14
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,33 @@
44
See also _lib._testing for additional private testing utilities.
55
"""
66

7-
# https://github.com/scikit-learn/scikit-learn/pull/27910#issuecomment-2568023972
87
from __future__ import annotations
98

109
import contextlib
1110
from collections.abc import Callable, Iterable, Iterator, Sequence
1211
from functools import wraps
1312
from types import ModuleType
14-
from typing import TYPE_CHECKING, Any, TypeVar, cast
13+
from typing import TYPE_CHECKING, Any, ParamSpec, TypeVar, cast
1514

1615
from ._lib._utils._compat import is_dask_namespace, is_jax_namespace
1716

1817
__all__ = ["lazy_xp_function", "patch_lazy_xp_functions"]
1918

2019
if TYPE_CHECKING: # pragma: no cover
21-
# TODO move ParamSpec outside TYPE_CHECKING
22-
# depends on scikit-learn abandoning Python 3.9
23-
# https://github.com/scikit-learn/scikit-learn/pull/27910#issuecomment-2568023972
24-
from typing import ParamSpec
25-
20+
# TODO import override from typing (requires Python >=3.12)
2621
import pytest
2722
from dask.typing import Graph, Key, SchedulerGetCallable
2823
from typing_extensions import override
2924

30-
P = ParamSpec("P")
3125
else:
32-
SchedulerGetCallable = object
33-
3426
# Sphinx hacks
35-
class P: # pylint: disable=missing-class-docstring
36-
args: tuple
37-
kwargs: dict
27+
SchedulerGetCallable = object
3828

39-
def override(func: Callable[P, T]) -> Callable[P, T]:
29+
def override(func: object) -> object:
4030
return func
4131

4232

33+
P = ParamSpec("P")
4334
T = TypeVar("T")
4435

4536
_ufuncs_tags: dict[object, dict[str, Any]] = {} # type: ignore[explicit-any]

0 commit comments

Comments
 (0)