From 6ca00db931300abfe0804a777094d93a8833eab2 Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Thu, 1 Jul 2021 17:35:17 -0700 Subject: [PATCH] DO NOT MERGE make classmethod and staticmethod generic. --- pytype/stubs/builtins/3/builtins.pytd | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pytype/stubs/builtins/3/builtins.pytd b/pytype/stubs/builtins/3/builtins.pytd index 3844bf119..34f0f1457 100644 --- a/pytype/stubs/builtins/3/builtins.pytd +++ b/pytype/stubs/builtins/3/builtins.pytd @@ -26,6 +26,7 @@ _NUMBER = TypeVar('_NUMBER', bound=complex) # See b/142884093. We redefine AnyStr rather than importing it to avoid pytype # mistakenly treating it as a public builtin. _AnyStr = TypeVar('_AnyStr', bytes, str) +_FuncT = TypeVar("_FuncT", bound=Callable[..., Any]) # isinstance() and issubclass() can take a type or an arbitrarily nested # tuple of types. This adds support for a few levels; in theory we want @@ -207,15 +208,15 @@ class property(object): def __delete__(self, *args, **kwargs) -> Any: ... # staticmethod and classmethod are handled in special_builtins.py. -class staticmethod(typing.Callable): +class staticmethod(typing.Callable, Generic[_FuncT]): __slots__ = [] - def __init__(self, func) -> NoneType: ... - def __get__(self, *args, **kwargs) -> Any: ... + def __init__(self, __f: _FuncT) -> NoneType: ... + def __get__(self, *args, **kwargs) -> _FuncT: ... -class classmethod(typing.Callable): +class classmethod(typing.Callable, Generic[_T]): __slots__ = [] - def __init__(self, func) -> NoneType: ... - def __get__(self, *args, **kwargs) -> Any: ... + def __init__(self, __f: Callable[..., _T]) -> NoneType: ... + def __get__(self, *args, **kwargs) -> Callable[..., _T]: ... _T_str = TypeVar('_T_str', bound=str) class str(Sequence[str], Hashable):