From 659af0698ee59f565f53c8d73bdf7ed9f6a44b8f Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Fri, 24 Mar 2017 17:58:38 +0300 Subject: [PATCH 1/2] Update stubs for `classmethod` and `staticmethod` in both Pythons. --- stdlib/2/__builtin__.pyi | 17 +++++++++++++++-- stdlib/3/builtins.pyi | 17 +++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index e8cc5aee10f8..5ddbcc89dbc1 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -25,8 +25,21 @@ _T4 = TypeVar('_T4') _T5 = TypeVar('_T5') _TT = TypeVar('_TT', bound='type') -class staticmethod: ... # Special, only valid as a decorator. -class classmethod: ... # Special, only valid as a decorator. +class staticmethod: # Special, only valid as a decorator. + __func__ = ... # type: function + + def __init__(self, f: function) -> None: ... + def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... + def __get__(self, obj: _T, type: Type[_T]=None) -> function: ... + def __getattribute__(self, name: str) -> Any: ... + +class classmethod: # Special, only valid as a decorator. + __func__ = ... # type: function + + def __init__(self, f: function) -> None: ... + def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... + def __get__(self, obj: _T, type: Type[_T]=None) -> function: ... + def __getattribute__(self, name: str) -> Any: ... class object: __doc__ = ... # type: Optional[str] diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 2b0f40249a87..30c6194fd57e 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -27,8 +27,21 @@ _T4 = TypeVar('_T4') _T5 = TypeVar('_T5') _TT = TypeVar('_TT', bound='type') -class staticmethod: ... # Special, only valid as a decorator. -class classmethod: ... # Special, only valid as a decorator. +class staticmethod: # Special, only valid as a decorator. + __func__ = ... # type: function + __isabstractmethod__ = ... # type: bool + + def __init__(self, f: function) -> None: ... + def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... + def __get__(self, obj: _T, type: Type[_T]=None) -> function: ... + +class classmethod: # Special, only valid as a decorator. + __func__ = ... # type: function + __isabstractmethod__ = ... # type: bool + + def __init__(self, f: function) -> None: ... + def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... + def __get__(self, obj: _T, type: Type[_T]=None) -> function: ... class object: __doc__ = ... # type: Optional[str] From e74c5f50a3781b7698a308fd28b898b204634127 Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Wed, 29 Mar 2017 18:52:32 +0300 Subject: [PATCH 2/2] Inherit `classmethod` and `staticmethod` from `object` in Python 2 --- stdlib/2/__builtin__.pyi | 30 ++++++++++++++---------------- stdlib/3/builtins.pyi | 32 ++++++++++++++++---------------- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index 5ddbcc89dbc1..fe19774df801 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -25,22 +25,6 @@ _T4 = TypeVar('_T4') _T5 = TypeVar('_T5') _TT = TypeVar('_TT', bound='type') -class staticmethod: # Special, only valid as a decorator. - __func__ = ... # type: function - - def __init__(self, f: function) -> None: ... - def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... - def __get__(self, obj: _T, type: Type[_T]=None) -> function: ... - def __getattribute__(self, name: str) -> Any: ... - -class classmethod: # Special, only valid as a decorator. - __func__ = ... # type: function - - def __init__(self, f: function) -> None: ... - def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... - def __get__(self, obj: _T, type: Type[_T]=None) -> function: ... - def __getattribute__(self, name: str) -> Any: ... - class object: __doc__ = ... # type: Optional[str] __class__ = ... # type: type @@ -62,6 +46,20 @@ class object: def __reduce__(self) -> tuple: ... def __reduce_ex__(self, protocol: int) -> tuple: ... +class staticmethod(object): # Special, only valid as a decorator. + __func__ = ... # type: function + + def __init__(self, f: function) -> None: ... + def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... + def __get__(self, obj: _T, type: Optional[Type[_T]]=...) -> function: ... + +class classmethod(object): # Special, only valid as a decorator. + __func__ = ... # type: function + + def __init__(self, f: function) -> None: ... + def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... + def __get__(self, obj: _T, type: Optional[Type[_T]]=...) -> function: ... + class type(object): __bases__ = ... # type: Tuple[type, ...] __name__ = ... # type: str diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 30c6194fd57e..0910e98605a0 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -27,22 +27,6 @@ _T4 = TypeVar('_T4') _T5 = TypeVar('_T5') _TT = TypeVar('_TT', bound='type') -class staticmethod: # Special, only valid as a decorator. - __func__ = ... # type: function - __isabstractmethod__ = ... # type: bool - - def __init__(self, f: function) -> None: ... - def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... - def __get__(self, obj: _T, type: Type[_T]=None) -> function: ... - -class classmethod: # Special, only valid as a decorator. - __func__ = ... # type: function - __isabstractmethod__ = ... # type: bool - - def __init__(self, f: function) -> None: ... - def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... - def __get__(self, obj: _T, type: Type[_T]=None) -> function: ... - class object: __doc__ = ... # type: Optional[str] __class__ = ... # type: type @@ -70,6 +54,22 @@ class object: if sys.version_info >= (3, 6): def __init_subclass__(cls) -> None: ... +class staticmethod: # Special, only valid as a decorator. + __func__ = ... # type: function + __isabstractmethod__ = ... # type: bool + + def __init__(self, f: function) -> None: ... + def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... + def __get__(self, obj: _T, type: Optional[Type[_T]]=...) -> function: ... + +class classmethod: # Special, only valid as a decorator. + __func__ = ... # type: function + __isabstractmethod__ = ... # type: bool + + def __init__(self, f: function) -> None: ... + def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... + def __get__(self, obj: _T, type: Optional[Type[_T]]=...) -> function: ... + class type: __bases__ = ... # type: Tuple[type, ...] __name__ = ... # type: str