Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
overrides.pyi48 linesDownload Raw Back to _core
1from collections.abc import Callable, Iterable
2from typing import Any, Final, NamedTuple, ParamSpec, TypeAlias, TypeVar
3
4from numpy._utils import set_module as set_module
5
6_T = TypeVar("_T")
7_Tss = ParamSpec("_Tss")
8_FuncLikeT = TypeVar("_FuncLikeT", bound=type | Callable[..., object])
9
10_Dispatcher: TypeAlias = Callable[_Tss, Iterable[object]]
11
12###
13
14ARRAY_FUNCTIONS: set[Callable[..., Any]] = ...
15array_function_like_doc: Final[str] = ...
16
17class ArgSpec(NamedTuple):
18    args: list[str]
19    varargs: str | None
20    keywords: str | None
21    defaults: tuple[Any, ...]
22
23def get_array_function_like_doc(public_api: Callable[..., object], docstring_template: str = "") -> str: ...
24def finalize_array_function_like(public_api: _FuncLikeT) -> _FuncLikeT: ...
25
26#
27def verify_matching_signatures(implementation: Callable[_Tss, object], dispatcher: _Dispatcher[_Tss]) -> None: ...
28
29# NOTE: This actually returns a `_ArrayFunctionDispatcher` callable wrapper object, with
30# the original wrapped callable stored in the `._implementation` attribute. It checks
31# for any `__array_function__` of the values of specific arguments that the dispatcher
32# specifies. Since the dispatcher only returns an iterable of passed array-like args,
33# this overridable behaviour is impossible to annotate.
34def array_function_dispatch(
35    dispatcher: _Dispatcher[_Tss] | None = None,
36    module: str | None = None,
37    verify: bool = True,
38    docs_from_dispatcher: bool = False,
39) -> Callable[[_FuncLikeT], _FuncLikeT]: ...
40
41#
42def array_function_from_dispatcher(
43    implementation: Callable[_Tss, _T],
44    module: str | None = None,
45    verify: bool = True,
46    docs_from_dispatcher: bool = True,
47) -> Callable[[_Dispatcher[_Tss]], Callable[_Tss, _T]]: ...
48 
codekingpro/portable-devtools · Team Ai