From d989dc70fa83df9ff6d0206ff8d7ba6dead8040c Mon Sep 17 00:00:00 2001 From: "Michael J. Sullivan" Date: Tue, 25 Sep 2018 17:16:09 -0700 Subject: [PATCH] Revert "Revert "make __class__ refer to the current object's class (#1549)" (#1632)" This reverts commit 78587dc89597fa2019e037700f0007607933ce73. --- stdlib/2/__builtin__.pyi | 7 +++++-- stdlib/2/builtins.pyi | 7 +++++-- stdlib/2/types.pyi | 1 - stdlib/3/builtins.pyi | 5 ++++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index 45a6f7709e6f..f0f99935306d 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -11,7 +11,7 @@ from typing import ( SupportsComplex, SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping, MutableSet, ItemsView, KeysView, ValuesView, Optional, Container, Type ) -from abc import abstractmethod, ABCMeta +from abc import ABCMeta _T = TypeVar('_T') _T_co = TypeVar('_T_co', covariant=True) @@ -27,11 +27,14 @@ _TT = TypeVar('_TT', bound='type') class object: __doc__ = ... # type: Optional[str] - __class__ = ... # type: type __dict__ = ... # type: Dict[str, Any] __slots__ = ... # type: Union[str, unicode, Iterable[Union[str, unicode]]] __module__ = ... # type: str + @property + def __class__(self: _T) -> Type[_T]: ... + @__class__.setter + def __class__(self, __type: Type[object]) -> None: ... def __init__(self) -> None: ... def __new__(cls) -> Any: ... def __setattr__(self, name: str, value: Any) -> None: ... diff --git a/stdlib/2/builtins.pyi b/stdlib/2/builtins.pyi index 45a6f7709e6f..f0f99935306d 100644 --- a/stdlib/2/builtins.pyi +++ b/stdlib/2/builtins.pyi @@ -11,7 +11,7 @@ from typing import ( SupportsComplex, SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping, MutableSet, ItemsView, KeysView, ValuesView, Optional, Container, Type ) -from abc import abstractmethod, ABCMeta +from abc import ABCMeta _T = TypeVar('_T') _T_co = TypeVar('_T_co', covariant=True) @@ -27,11 +27,14 @@ _TT = TypeVar('_TT', bound='type') class object: __doc__ = ... # type: Optional[str] - __class__ = ... # type: type __dict__ = ... # type: Dict[str, Any] __slots__ = ... # type: Union[str, unicode, Iterable[Union[str, unicode]]] __module__ = ... # type: str + @property + def __class__(self: _T) -> Type[_T]: ... + @__class__.setter + def __class__(self, __type: Type[object]) -> None: ... def __init__(self) -> None: ... def __new__(cls) -> Any: ... def __setattr__(self, name: str, value: Any) -> None: ... diff --git a/stdlib/2/types.pyi b/stdlib/2/types.pyi index 4e19c9785b47..ac6db26456e4 100644 --- a/stdlib/2/types.pyi +++ b/stdlib/2/types.pyi @@ -90,7 +90,6 @@ class UnboundMethodType: class InstanceType: __doc__ = ... # type: Optional[str] - __class__ = ... # type: type __module__ = ... # type: Any MethodType = UnboundMethodType diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 291751ad1aab..b75254d06dde 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -28,13 +28,16 @@ _TT = TypeVar('_TT', bound='type') class object: __doc__ = ... # type: Optional[str] - __class__ = ... # type: type __dict__ = ... # type: Dict[str, Any] __slots__ = ... # type: Union[str, Iterable[str]] __module__ = ... # type: str if sys.version_info >= (3, 6): __annotations__ = ... # type: Dict[str, Any] + @property + def __class__(self: _T) -> Type[_T]: ... + @__class__.setter + def __class__(self, __type: Type[object]) -> None: ... def __init__(self) -> None: ... def __new__(cls) -> Any: ... def __setattr__(self, name: str, value: Any) -> None: ...