massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / functools.pyi
1 import sys
2 import types
3 from _typeshed import SupportsItems, SupportsLessThan
4 from typing import Any, Callable, Generic, Hashable, Iterable, NamedTuple, Sequence, Sized, Tuple, Type, TypeVar, overload
5 from typing_extensions import final
6
7 if sys.version_info >= (3, 9):
8     from types import GenericAlias
9
10 _AnyCallable = Callable[..., Any]
11
12 _T = TypeVar("_T")
13 _S = TypeVar("_S")
14
15 @overload
16 def reduce(function: Callable[[_T, _S], _T], sequence: Iterable[_S], initial: _T) -> _T: ...
17 @overload
18 def reduce(function: Callable[[_T, _T], _T], sequence: Iterable[_T]) -> _T: ...
19
20 class _CacheInfo(NamedTuple):
21     hits: int
22     misses: int
23     maxsize: int
24     currsize: int
25
26 @final
27 class _lru_cache_wrapper(Generic[_T]):
28     __wrapped__: Callable[..., _T]
29     def __call__(self, *args: Hashable, **kwargs: Hashable) -> _T: ...
30     def cache_info(self) -> _CacheInfo: ...
31     def cache_clear(self) -> None: ...
32
33 if sys.version_info >= (3, 8):
34     @overload
35     def lru_cache(maxsize: int | None = ..., typed: bool = ...) -> Callable[[Callable[..., _T]], _lru_cache_wrapper[_T]]: ...
36     @overload
37     def lru_cache(maxsize: Callable[..., _T], typed: bool = ...) -> _lru_cache_wrapper[_T]: ...
38
39 else:
40     def lru_cache(maxsize: int | None = ..., typed: bool = ...) -> Callable[[Callable[..., _T]], _lru_cache_wrapper[_T]]: ...
41
42 WRAPPER_ASSIGNMENTS: Sequence[str]
43 WRAPPER_UPDATES: Sequence[str]
44
45 def update_wrapper(wrapper: _T, wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> _T: ...
46 def wraps(wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> Callable[[_T], _T]: ...
47 def total_ordering(cls: Type[_T]) -> Type[_T]: ...
48 def cmp_to_key(mycmp: Callable[[_T, _T], int]) -> Callable[[_T], SupportsLessThan]: ...
49
50 class partial(Generic[_T]):
51     func: Callable[..., _T]
52     args: Tuple[Any, ...]
53     keywords: dict[str, Any]
54     def __init__(self, func: Callable[..., _T], *args: Any, **kwargs: Any) -> None: ...
55     def __call__(self, *args: Any, **kwargs: Any) -> _T: ...
56     if sys.version_info >= (3, 9):
57         def __class_getitem__(cls, item: Any) -> GenericAlias: ...
58
59 # With protocols, this could change into a generic protocol that defines __get__ and returns _T
60 _Descriptor = Any
61
62 class partialmethod(Generic[_T]):
63     func: Callable[..., _T] | _Descriptor
64     args: Tuple[Any, ...]
65     keywords: dict[str, Any]
66     @overload
67     def __init__(self, __func: Callable[..., _T], *args: Any, **keywords: Any) -> None: ...
68     @overload
69     def __init__(self, __func: _Descriptor, *args: Any, **keywords: Any) -> None: ...
70     def __get__(self, obj: Any, cls: Type[Any]) -> Callable[..., _T]: ...
71     @property
72     def __isabstractmethod__(self) -> bool: ...
73     if sys.version_info >= (3, 9):
74         def __class_getitem__(cls, item: Any) -> GenericAlias: ...
75
76 class _SingleDispatchCallable(Generic[_T]):
77     registry: types.MappingProxyType[Any, Callable[..., _T]]
78     def dispatch(self, cls: Any) -> Callable[..., _T]: ...
79     # @fun.register(complex)
80     # def _(arg, verbose=False): ...
81     @overload
82     def register(self, cls: Type[Any], func: None = ...) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
83     # @fun.register
84     # def _(arg: int, verbose=False):
85     @overload
86     def register(self, cls: Callable[..., _T], func: None = ...) -> Callable[..., _T]: ...
87     # fun.register(int, lambda x: x)
88     @overload
89     def register(self, cls: Type[Any], func: Callable[..., _T]) -> Callable[..., _T]: ...
90     def _clear_cache(self) -> None: ...
91     def __call__(self, *args: Any, **kwargs: Any) -> _T: ...
92
93 def singledispatch(func: Callable[..., _T]) -> _SingleDispatchCallable[_T]: ...
94
95 if sys.version_info >= (3, 8):
96     class singledispatchmethod(Generic[_T]):
97         dispatcher: _SingleDispatchCallable[_T]
98         func: Callable[..., _T]
99         def __init__(self, func: Callable[..., _T]) -> None: ...
100         @overload
101         def register(self, cls: Type[Any], method: None = ...) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
102         @overload
103         def register(self, cls: Callable[..., _T], method: None = ...) -> Callable[..., _T]: ...
104         @overload
105         def register(self, cls: Type[Any], method: Callable[..., _T]) -> Callable[..., _T]: ...
106         def __call__(self, *args: Any, **kwargs: Any) -> _T: ...
107     class cached_property(Generic[_T]):
108         func: Callable[[Any], _T]
109         attrname: str | None
110         def __init__(self, func: Callable[[Any], _T]) -> None: ...
111         @overload
112         def __get__(self, instance: None, owner: Type[Any] | None = ...) -> cached_property[_T]: ...
113         @overload
114         def __get__(self, instance: object, owner: Type[Any] | None = ...) -> _T: ...
115         def __set_name__(self, owner: Type[Any], name: str) -> None: ...
116         if sys.version_info >= (3, 9):
117             def __class_getitem__(cls, item: Any) -> GenericAlias: ...
118
119 if sys.version_info >= (3, 9):
120     def cache(__user_function: Callable[..., _T]) -> _lru_cache_wrapper[_T]: ...
121
122 def _make_key(
123     args: Tuple[Hashable, ...],
124     kwds: SupportsItems[Any, Any],
125     typed: bool,
126     kwd_mark: Tuple[object, ...] = ...,
127     fasttypes: set[type] = ...,
128     tuple: type = ...,
129     type: Any = ...,
130     len: Callable[[Sized], int] = ...,
131 ) -> Hashable: ...