overrides.pyi 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from collections.abc import Callable, Iterable
  2. from typing import Any, Final, NamedTuple
  3. from typing_extensions import ParamSpec, TypeVar
  4. from numpy._typing import _SupportsArrayFunc
  5. _T = TypeVar("_T")
  6. _Tss = ParamSpec("_Tss")
  7. _FuncT = TypeVar("_FuncT", bound=Callable[..., 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[..., Any], docstring_template: str = "") -> str: ...
  17. def finalize_array_function_like(public_api: _FuncT) -> _FuncT: ...
  18. #
  19. def verify_matching_signatures(
  20. implementation: Callable[_Tss, object],
  21. dispatcher: Callable[_Tss, Iterable[_SupportsArrayFunc]],
  22. ) -> None: ...
  23. # NOTE: This actually returns a `_ArrayFunctionDispatcher` callable wrapper object, with
  24. # the original wrapped callable stored in the `._implementation` attribute. It checks
  25. # for any `__array_function__` of the values of specific arguments that the dispatcher
  26. # specifies. Since the dispatcher only returns an iterable of passed array-like args,
  27. # this overridable behaviour is impossible to annotate.
  28. def array_function_dispatch(
  29. dispatcher: Callable[_Tss, Iterable[_SupportsArrayFunc]] | None = None,
  30. module: str | None = None,
  31. verify: bool = True,
  32. docs_from_dispatcher: bool = False,
  33. ) -> Callable[[_FuncT], _FuncT]: ...
  34. #
  35. def array_function_from_dispatcher(
  36. implementation: Callable[_Tss, _T],
  37. module: str | None = None,
  38. verify: bool = True,
  39. docs_from_dispatcher: bool = True,
  40. ) -> Callable[[Callable[_Tss, Iterable[_SupportsArrayFunc]]], Callable[_Tss, _T]]: ...