diff --git a/stdlib/3/functools.pyi b/stdlib/3/functools.pyi index c24faf811..29866a18c 100644 --- a/stdlib/3/functools.pyi +++ b/stdlib/3/functools.pyi @@ -3,7 +3,8 @@ # NOTE: These are incomplete! from abc import ABCMeta, abstractmethod -from typing import Any, Callable, Generic, Dict, Iterable, Optional, Sequence, Tuple, TypeVar, NamedTuple, overload +import sys +from typing import Any, Callable, Generic, Dict, Iterable, Mapping, Optional, Sequence, Tuple, TypeVar, NamedTuple, overload from collections import namedtuple _AnyCallable = Callable[..., Any] @@ -43,8 +44,21 @@ def total_ordering(cls: type) -> type: ... def cmp_to_key(mycmp: Callable[[_T, _T], int]) -> Callable[[_T], Any]: ... class partial(Generic[_T]): - func = ... # Callable[..., _T] + func = ... # type: Callable[..., _T] args = ... # type: Tuple[Any, ...] keywords = ... # type: Dict[str, Any] def __init__(self, func: Callable[..., _T], *args: Any, **kwargs: Any) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> _T: ... + +if sys.version_info >= (3, 4): + class _SingleDispatchCallable(Generic[_T]): + registry = ... # type: Mapping[Any, Callable[..., _T]] + def dispatch(self, cls: Any) -> Callable[..., _T]: ... + @overload + def register(self, cls: Any) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... + @overload + def register(self, cls: Any, func: Callable[..., _T]) -> Callable[..., _T]: ... + def _clear_cache(self) -> None: ... + def __call__(self, *args: Any, **kwargs: Any) -> _T: ... + + def singledispatch(func: Callable[..., _T]) -> _SingleDispatchCallable[_T]: ... diff --git a/third_party/2and3/singledispatch.pyi b/third_party/2and3/singledispatch.pyi index dac3ceae8..ed24b7f1f 100644 --- a/third_party/2and3/singledispatch.pyi +++ b/third_party/2and3/singledispatch.pyi @@ -1,5 +1,17 @@ -# Stubs for singledispatch (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. +from typing import Any, Callable, Generic, Mapping, Optional, TypeVar, overload -def singledispatch(func): ... + +_T = TypeVar("_T") + + +class _SingleDispatchCallable(Generic[_T]): + registry = ... # type: Mapping[Any, Callable[..., _T]] + def dispatch(self, cls: Any) -> Callable[..., _T]: ... + @overload + def register(self, cls: Any) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... + @overload + def register(self, cls: Any, func: Callable[..., _T]) -> Callable[..., _T]: ... + def _clear_cache(self) -> None: ... + def __call__(self, *args: Any, **kwargs: Any) -> _T: ... + +def singledispatch(func: Callable[..., _T]) -> _SingleDispatchCallable[_T]: ...