|
4 | 4 | See also _lib._testing for additional private testing utilities. |
5 | 5 | """ |
6 | 6 |
|
7 | | -# https://github.com/scikit-learn/scikit-learn/pull/27910#issuecomment-2568023972 |
8 | 7 | from __future__ import annotations |
9 | 8 |
|
10 | 9 | import contextlib |
11 | 10 | from collections.abc import Callable, Iterable, Iterator, Sequence |
12 | 11 | from functools import wraps |
13 | 12 | from types import ModuleType |
14 | | -from typing import TYPE_CHECKING, Any, TypeVar, cast |
| 13 | +from typing import TYPE_CHECKING, Any, ParamSpec, TypeVar, cast |
15 | 14 |
|
16 | 15 | from ._lib._utils._compat import is_dask_namespace, is_jax_namespace |
17 | 16 |
|
18 | 17 | __all__ = ["lazy_xp_function", "patch_lazy_xp_functions"] |
19 | 18 |
|
20 | 19 | 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) |
26 | 21 | import pytest |
27 | 22 | from dask.typing import Graph, Key, SchedulerGetCallable |
28 | 23 | from typing_extensions import override |
29 | 24 |
|
30 | | - P = ParamSpec("P") |
31 | 25 | else: |
32 | | - SchedulerGetCallable = object |
33 | | - |
34 | 26 | # Sphinx hacks |
35 | | - class P: # pylint: disable=missing-class-docstring |
36 | | - args: tuple |
37 | | - kwargs: dict |
| 27 | + SchedulerGetCallable = object |
38 | 28 |
|
39 | | - def override(func: Callable[P, T]) -> Callable[P, T]: |
| 29 | + def override(func: object) -> object: |
40 | 30 | return func |
41 | 31 |
|
42 | 32 |
|
| 33 | +P = ParamSpec("P") |
43 | 34 | T = TypeVar("T") |
44 | 35 |
|
45 | 36 | _ufuncs_tags: dict[object, dict[str, Any]] = {} # type: ignore[explicit-any] |
|
0 commit comments