Skip to content

Commit 78587dc

Browse files
JelleZijlstragvanrossum
authored andcommitted
Revert "make __class__ refer to the current object's class (#1549)" (#1632)
This reverts commit 1a164b6. Reverts #1549. See Guido's comments in the original PR.
1 parent 1a164b6 commit 78587dc

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

stdlib/2/__builtin__.pyi

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ from typing import (
1010
SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping,
1111
MutableSet, ItemsView, KeysView, ValuesView, Optional, Container, Type
1212
)
13-
from abc import ABCMeta
13+
from abc import abstractmethod, ABCMeta
1414
from mypy_extensions import NoReturn
1515

1616
_T = TypeVar('_T')
@@ -27,13 +27,10 @@ _TT = TypeVar('_TT', bound='type')
2727

2828
class object:
2929
__doc__ = ... # type: Optional[str]
30+
__class__ = ... # type: type
3031
__slots__ = ... # type: Optional[Union[str, unicode, Iterable[Union[str, unicode]]]]
3132
__module__ = ... # type: str
3233

33-
@property
34-
def __class__(self: _T) -> Type[_T]: ...
35-
@__class__.setter
36-
def __class__(self, __type: Type[object]) -> None: ...
3734
def __init__(self) -> None: ...
3835
def __new__(cls) -> Any: ...
3936
def __setattr__(self, name: str, value: Any) -> None: ...

stdlib/2/types.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class UnboundMethodType:
9090

9191
class InstanceType:
9292
__doc__ = ... # type: Optional[str]
93+
__class__ = ... # type: type
9394
__module__ = ... # type: Any
9495

9596
MethodType = UnboundMethodType

stdlib/3/builtins.pyi

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,13 @@ _TT = TypeVar('_TT', bound='type')
2929

3030
class object:
3131
__doc__ = ... # type: Optional[str]
32+
__class__ = ... # type: type
3233
__dict__ = ... # type: Dict[str, Any]
3334
__slots__ = ... # type: Optional[Union[str, Iterable[str]]]
3435
__module__ = ... # type: str
3536
if sys.version_info >= (3, 6):
3637
__annotations__ = ... # type: Dict[str, Any]
3738

38-
@property
39-
def __class__(self: _T) -> Type[_T]: ...
40-
@__class__.setter
41-
def __class__(self, __type: Type[object]) -> None: ...
4239
def __init__(self) -> None: ...
4340
def __new__(cls) -> Any: ...
4441
def __setattr__(self, name: str, value: Any) -> None: ...

stdlib/3/unittest/mock.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ if sys.version_info >= (3, 3):
4242
def attach_mock(self, mock: Any, attribute: Any) -> Any: ...
4343
def mock_add_spec(self, spec: Any, spec_set: Any = False) -> Any: ...
4444
return_value = ... # type: Any
45+
__class__ = ... # type: type
4546
called = ... # type: Any
4647
call_count = ... # type: Any
4748
call_args = ... # type: Any

0 commit comments

Comments
 (0)