Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 65863be

Browse files
authored
make __class__ refer to the current object's class (#2480)
This is just a direct rehash of #1549.
1 parent 2e0af18 commit 65863be

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

stdlib/2/__builtin__.pyi

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ from typing import (
1111
SupportsComplex, SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping,
1212
MutableSet, ItemsView, KeysView, ValuesView, Optional, Container, Type
1313
)
14-
from abc import abstractmethod, ABCMeta
14+
from abc import ABCMeta
1515

1616
_T = TypeVar('_T')
1717
_T_co = TypeVar('_T_co', covariant=True)
@@ -27,11 +27,14 @@ _TT = TypeVar('_TT', bound='type')
2727

2828
class object:
2929
__doc__ = ... # type: Optional[str]
30-
__class__ = ... # type: type
3130
__dict__ = ... # type: Dict[str, Any]
3231
__slots__ = ... # type: Union[str, unicode, Iterable[Union[str, unicode]]]
3332
__module__ = ... # type: str
3433

34+
@property
35+
def __class__(self: _T) -> Type[_T]: ...
36+
@__class__.setter
37+
def __class__(self, __type: Type[object]) -> None: ...
3538
def __init__(self) -> None: ...
3639
def __new__(cls) -> Any: ...
3740
def __setattr__(self, name: str, value: Any) -> None: ...

stdlib/2/builtins.pyi

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ from typing import (
1111
SupportsComplex, SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping,
1212
MutableSet, ItemsView, KeysView, ValuesView, Optional, Container, Type
1313
)
14-
from abc import abstractmethod, ABCMeta
14+
from abc import ABCMeta
1515

1616
_T = TypeVar('_T')
1717
_T_co = TypeVar('_T_co', covariant=True)
@@ -27,11 +27,14 @@ _TT = TypeVar('_TT', bound='type')
2727

2828
class object:
2929
__doc__ = ... # type: Optional[str]
30-
__class__ = ... # type: type
3130
__dict__ = ... # type: Dict[str, Any]
3231
__slots__ = ... # type: Union[str, unicode, Iterable[Union[str, unicode]]]
3332
__module__ = ... # type: str
3433

34+
@property
35+
def __class__(self: _T) -> Type[_T]: ...
36+
@__class__.setter
37+
def __class__(self, __type: Type[object]) -> None: ...
3538
def __init__(self) -> None: ...
3639
def __new__(cls) -> Any: ...
3740
def __setattr__(self, name: str, value: Any) -> None: ...

stdlib/2/types.pyi

-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ class UnboundMethodType:
9090

9191
class InstanceType:
9292
__doc__ = ... # type: Optional[str]
93-
__class__ = ... # type: type
9493
__module__ = ... # type: Any
9594

9695
MethodType = UnboundMethodType

stdlib/3/builtins.pyi

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@ _TT = TypeVar('_TT', bound='type')
2828

2929
class object:
3030
__doc__ = ... # type: Optional[str]
31-
__class__ = ... # type: type
3231
__dict__ = ... # type: Dict[str, Any]
3332
__slots__ = ... # type: Union[str, Iterable[str]]
3433
__module__ = ... # type: str
3534
if sys.version_info >= (3, 6):
3635
__annotations__ = ... # type: Dict[str, Any]
3736

37+
@property
38+
def __class__(self: _T) -> Type[_T]: ...
39+
@__class__.setter
40+
def __class__(self, __type: Type[object]) -> None: ...
3841
def __init__(self) -> None: ...
3942
def __new__(cls) -> Any: ...
4043
def __setattr__(self, name: str, value: Any) -> None: ...

0 commit comments

Comments
 (0)