overrides.pyi 1.7 KB

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