@@ -69,8 +69,6 @@ _T2 = TypeVar("_T2")
6969_T3 = TypeVar ("_T3" )
7070_T4 = TypeVar ("_T4" )
7171_T5 = TypeVar ("_T5" )
72- _TT = TypeVar ("_TT" , bound = "type" )
73- _TBE = TypeVar ("_TBE" , bound = "BaseException" )
7472_R = TypeVar ("_R" ) # Return-type TypeVar
7573_SupportsNextT = TypeVar ("_SupportsNextT" , bound = SupportsNext [Any ], covariant = True )
7674_SupportsAnextT = TypeVar ("_SupportsAnextT" , bound = SupportsAnext [Any ], covariant = True )
@@ -87,12 +85,12 @@ class object:
8785 __module__ : str
8886 __annotations__ : dict [str , Any ]
8987 @property
90- def __class__ (self : _T ) -> type [_T ]: ...
88+ def __class__ (self : Self ) -> type [Self ]: ...
9189 # Ignore errors about type mismatch between property getter and setter
9290 @__class__ .setter
9391 def __class__ (self , __type : type [object ]) -> None : ... # type: ignore # noqa: F811
9492 def __init__ (self ) -> None : ...
95- def __new__ (cls : type [_T ]) -> _T : ...
93+ def __new__ (cls : type [Self ]) -> Self : ...
9694 def __setattr__ (self , __name : str , __value : Any ) -> None : ...
9795 def __eq__ (self , __o : object ) -> bool : ...
9896 def __ne__ (self , __o : object ) -> bool : ...
@@ -117,7 +115,7 @@ class staticmethod(Generic[_R]): # Special, only valid as a decorator.
117115 __func__ : Callable [..., _R ]
118116 __isabstractmethod__ : bool
119117 def __init__ (self : staticmethod [_R ], __f : Callable [..., _R ]) -> None : ...
120- def __new__ (cls : type [_T ], * args : Any , ** kwargs : Any ) -> _T : ...
118+ def __new__ (cls : type [Self ], * args : Any , ** kwargs : Any ) -> Self : ...
121119 def __get__ (self , __obj : _T , __type : type [_T ] | None = ...) -> Callable [..., _R ]: ...
122120 if sys .version_info >= (3 , 10 ):
123121 __name__ : str
@@ -129,7 +127,7 @@ class classmethod(Generic[_R]): # Special, only valid as a decorator.
129127 __func__ : Callable [..., _R ]
130128 __isabstractmethod__ : bool
131129 def __init__ (self : classmethod [_R ], __f : Callable [..., _R ]) -> None : ...
132- def __new__ (cls : type [_T ], * args : Any , ** kwargs : Any ) -> _T : ...
130+ def __new__ (cls : type [Self ], * args : Any , ** kwargs : Any ) -> Self : ...
133131 def __get__ (self , __obj : _T , __type : type [_T ] | None = ...) -> Callable [..., _R ]: ...
134132 if sys .version_info >= (3 , 10 ):
135133 __name__ : str
@@ -157,9 +155,9 @@ class type:
157155 @overload
158156 def __new__ (cls , __o : object ) -> type : ...
159157 @overload
160- def __new__ (cls : type [_TT ], __name : str , __bases : tuple [type , ...], __namespace : dict [str , Any ], ** kwds : Any ) -> _TT : ...
158+ def __new__ (cls : type [Self ], __name : str , __bases : tuple [type , ...], __namespace : dict [str , Any ], ** kwds : Any ) -> Self : ...
161159 def __call__ (self , * args : Any , ** kwds : Any ) -> Any : ...
162- def __subclasses__ (self : _TT ) -> list [_TT ]: ...
160+ def __subclasses__ (self : Self ) -> list [Self ]: ...
163161 # Note: the documentation doesn't specify what the return type is, the standard
164162 # implementation seems to be returning a list.
165163 def mro (self ) -> list [type ]: ...
@@ -184,9 +182,9 @@ _NegativeInteger = Literal[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -1
184182
185183class int :
186184 @overload
187- def __new__ (cls : type [_T ], __x : str | bytes | SupportsInt | SupportsIndex | SupportsTrunc = ...) -> _T : ...
185+ def __new__ (cls : type [Self ], __x : str | bytes | SupportsInt | SupportsIndex | SupportsTrunc = ...) -> Self : ...
188186 @overload
189- def __new__ (cls : type [_T ], __x : str | bytes | bytearray , base : SupportsIndex ) -> _T : ...
187+ def __new__ (cls : type [Self ], __x : str | bytes | bytearray , base : SupportsIndex ) -> Self : ...
190188 if sys .version_info >= (3 , 8 ):
191189 def as_integer_ratio (self ) -> tuple [int , Literal [1 ]]: ...
192190 @property
@@ -269,7 +267,7 @@ class int:
269267 def __index__ (self ) -> int : ...
270268
271269class float :
272- def __new__ (cls : type [_T ], x : SupportsFloat | SupportsIndex | str | bytes | bytearray = ...) -> _T : ...
270+ def __new__ (cls : type [Self ], x : SupportsFloat | SupportsIndex | str | bytes | bytearray = ...) -> Self : ...
273271 def as_integer_ratio (self ) -> tuple [int , int ]: ...
274272 def hex (self ) -> str : ...
275273 def is_integer (self ) -> bool : ...
@@ -326,9 +324,9 @@ class float:
326324
327325class complex :
328326 @overload
329- def __new__ (cls : type [_T ], real : float = ..., imag : float = ...) -> _T : ...
327+ def __new__ (cls : type [Self ], real : float = ..., imag : float = ...) -> Self : ...
330328 @overload
331- def __new__ (cls : type [_T ], real : str | SupportsComplex | SupportsIndex | complex ) -> _T : ...
329+ def __new__ (cls : type [Self ], real : str | SupportsComplex | SupportsIndex | complex ) -> Self : ...
332330 @property
333331 def real (self ) -> float : ...
334332 @property
@@ -359,9 +357,9 @@ class _FormatMapMapping(Protocol):
359357
360358class str (Sequence [str ]):
361359 @overload
362- def __new__ (cls : type [_T ], object : object = ...) -> _T : ...
360+ def __new__ (cls : type [Self ], object : object = ...) -> Self : ...
363361 @overload
364- def __new__ (cls : type [_T ], o : bytes , encoding : str = ..., errors : str = ...) -> _T : ...
362+ def __new__ (cls : type [Self ], o : bytes , encoding : str = ..., errors : str = ...) -> Self : ...
365363 def capitalize (self ) -> str : ...
366364 def casefold (self ) -> str : ...
367365 def center (self , __width : SupportsIndex , __fillchar : str = ...) -> str : ...
@@ -443,15 +441,15 @@ class str(Sequence[str]):
443441
444442class bytes (ByteString ):
445443 @overload
446- def __new__ (cls : type [_T ], __ints : Iterable [SupportsIndex ]) -> _T : ...
444+ def __new__ (cls : type [Self ], __ints : Iterable [SupportsIndex ]) -> Self : ...
447445 @overload
448- def __new__ (cls : type [_T ], __string : str , encoding : str , errors : str = ...) -> _T : ...
446+ def __new__ (cls : type [Self ], __string : str , encoding : str , errors : str = ...) -> Self : ...
449447 @overload
450- def __new__ (cls : type [_T ], __length : SupportsIndex ) -> _T : ...
448+ def __new__ (cls : type [Self ], __length : SupportsIndex ) -> Self : ...
451449 @overload
452- def __new__ (cls : type [_T ]) -> _T : ...
450+ def __new__ (cls : type [Self ]) -> Self : ...
453451 @overload
454- def __new__ (cls : type [_T ], __o : SupportsBytes ) -> _T : ...
452+ def __new__ (cls : type [Self ], __o : SupportsBytes ) -> Self : ...
455453 def capitalize (self ) -> bytes : ...
456454 def center (self , __width : SupportsIndex , __fillchar : bytes = ...) -> bytes : ...
457455 def count (
@@ -705,7 +703,7 @@ class memoryview(Sized, Sequence[int]):
705703
706704@final
707705class bool (int ):
708- def __new__ (cls : type [_T ], __o : object = ...) -> _T : ...
706+ def __new__ (cls : type [Self ], __o : object = ...) -> Self : ...
709707 @overload
710708 def __and__ (self , __x : bool ) -> bool : ...
711709 @overload
@@ -748,7 +746,7 @@ class slice:
748746 def indices (self , __len : SupportsIndex ) -> tuple [int , int , int ]: ...
749747
750748class tuple (Sequence [_T_co ], Generic [_T_co ]):
751- def __new__ (cls : type [_T ], __iterable : Iterable [_T_co ] = ...) -> _T : ...
749+ def __new__ (cls : type [Self ], __iterable : Iterable [_T_co ] = ...) -> Self : ...
752750 def __len__ (self ) -> int : ...
753751 def __contains__ (self , __x : object ) -> bool : ...
754752 @overload
@@ -820,10 +818,10 @@ class list(MutableSequence[_T], Generic[_T]):
820818 def __setitem__ (self , __s : slice , __o : Iterable [_T ]) -> None : ...
821819 def __delitem__ (self , __i : SupportsIndex | slice ) -> None : ...
822820 def __add__ (self , __x : list [_T ]) -> list [_T ]: ...
823- def __iadd__ (self : _S , __x : Iterable [_T ]) -> _S : ...
821+ def __iadd__ (self : Self , __x : Iterable [_T ]) -> Self : ...
824822 def __mul__ (self , __n : SupportsIndex ) -> list [_T ]: ...
825823 def __rmul__ (self , __n : SupportsIndex ) -> list [_T ]: ...
826- def __imul__ (self : _S , __n : SupportsIndex ) -> _S : ...
824+ def __imul__ (self : Self , __n : SupportsIndex ) -> Self : ...
827825 def __contains__ (self , __o : object ) -> bool : ...
828826 def __reversed__ (self ) -> Iterator [_T ]: ...
829827 def __gt__ (self , __x : list [_T ]) -> bool : ...
@@ -847,7 +845,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
847845 # Cannot be Iterable[Sequence[_T]] or otherwise dict(["foo", "bar", "baz"]) is not an error
848846 @overload
849847 def __init__ (self : dict [str , str ], __iterable : Iterable [list [str ]]) -> None : ...
850- def __new__ (cls : type [_T1 ], * args : Any , ** kwargs : Any ) -> _T1 : ...
848+ def __new__ (cls : type [Self ], * args : Any , ** kwargs : Any ) -> Self : ...
851849 def copy (self ) -> dict [_KT , _VT ]: ...
852850 def keys (self ) -> dict_keys [_KT , _VT ]: ...
853851 def values (self ) -> dict_values [_KT , _VT ]: ...
@@ -1523,7 +1521,7 @@ class BaseException:
15231521 if sys .version_info >= (3 , 11 ):
15241522 __note__ : str | None
15251523 def __init__ (self , * args : object ) -> None : ...
1526- def with_traceback (self : _TBE , __tb : TracebackType | None ) -> _TBE : ...
1524+ def with_traceback (self : Self , __tb : TracebackType | None ) -> Self : ...
15271525
15281526class GeneratorExit (BaseException ): ...
15291527class KeyboardInterrupt (BaseException ): ...
0 commit comments