Use PEP 570 syntax in stdlib (#11250)

This commit is contained in:
Shantanu
2024-03-09 14:50:16 -08:00
committed by GitHub
parent 63737acac6
commit 470a13ab09
139 changed files with 2412 additions and 2371 deletions

View File

@@ -66,8 +66,8 @@ _VT_co = TypeVar("_VT_co", covariant=True)
@final
class _Cell:
def __new__(cls, __contents: object = ...) -> Self: ...
def __eq__(self, __value: object) -> bool: ...
def __new__(cls, contents: object = ..., /) -> Self: ...
def __eq__(self, value: object, /) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment]
cell_contents: Any
@@ -102,15 +102,15 @@ class FunctionType:
) -> Self: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
@overload
def __get__(self, __instance: None, __owner: type) -> FunctionType: ...
def __get__(self, instance: None, owner: type, /) -> FunctionType: ...
@overload
def __get__(self, __instance: object, __owner: type | None = None) -> MethodType: ...
def __get__(self, instance: object, owner: type | None = None, /) -> MethodType: ...
LambdaType = FunctionType
@final
class CodeType:
def __eq__(self, __value: object) -> bool: ...
def __eq__(self, value: object, /) -> bool: ...
def __hash__(self) -> int: ...
@property
def co_argcount(self) -> int: ...
@@ -164,64 +164,67 @@ class CodeType:
if sys.version_info >= (3, 11):
def __new__(
cls,
__argcount: int,
__posonlyargcount: int,
__kwonlyargcount: int,
__nlocals: int,
__stacksize: int,
__flags: int,
__codestring: bytes,
__constants: tuple[object, ...],
__names: tuple[str, ...],
__varnames: tuple[str, ...],
__filename: str,
__name: str,
__qualname: str,
__firstlineno: int,
__linetable: bytes,
__exceptiontable: bytes,
__freevars: tuple[str, ...] = ...,
__cellvars: tuple[str, ...] = ...,
argcount: int,
posonlyargcount: int,
kwonlyargcount: int,
nlocals: int,
stacksize: int,
flags: int,
codestring: bytes,
constants: tuple[object, ...],
names: tuple[str, ...],
varnames: tuple[str, ...],
filename: str,
name: str,
qualname: str,
firstlineno: int,
linetable: bytes,
exceptiontable: bytes,
freevars: tuple[str, ...] = ...,
cellvars: tuple[str, ...] = ...,
/,
) -> Self: ...
elif sys.version_info >= (3, 10):
def __new__(
cls,
__argcount: int,
__posonlyargcount: int,
__kwonlyargcount: int,
__nlocals: int,
__stacksize: int,
__flags: int,
__codestring: bytes,
__constants: tuple[object, ...],
__names: tuple[str, ...],
__varnames: tuple[str, ...],
__filename: str,
__name: str,
__firstlineno: int,
__linetable: bytes,
__freevars: tuple[str, ...] = ...,
__cellvars: tuple[str, ...] = ...,
argcount: int,
posonlyargcount: int,
kwonlyargcount: int,
nlocals: int,
stacksize: int,
flags: int,
codestring: bytes,
constants: tuple[object, ...],
names: tuple[str, ...],
varnames: tuple[str, ...],
filename: str,
name: str,
firstlineno: int,
linetable: bytes,
freevars: tuple[str, ...] = ...,
cellvars: tuple[str, ...] = ...,
/,
) -> Self: ...
else:
def __new__(
cls,
__argcount: int,
__posonlyargcount: int,
__kwonlyargcount: int,
__nlocals: int,
__stacksize: int,
__flags: int,
__codestring: bytes,
__constants: tuple[object, ...],
__names: tuple[str, ...],
__varnames: tuple[str, ...],
__filename: str,
__name: str,
__firstlineno: int,
__lnotab: bytes,
__freevars: tuple[str, ...] = ...,
__cellvars: tuple[str, ...] = ...,
argcount: int,
posonlyargcount: int,
kwonlyargcount: int,
nlocals: int,
stacksize: int,
flags: int,
codestring: bytes,
constants: tuple[object, ...],
names: tuple[str, ...],
varnames: tuple[str, ...],
filename: str,
name: str,
firstlineno: int,
lnotab: bytes,
freevars: tuple[str, ...] = ...,
cellvars: tuple[str, ...] = ...,
/,
) -> Self: ...
if sys.version_info >= (3, 11):
def replace(
@@ -293,10 +296,10 @@ class CodeType:
class MappingProxyType(Mapping[_KT, _VT_co]):
__hash__: ClassVar[None] # type: ignore[assignment]
def __new__(cls, mapping: SupportsKeysAndGetItem[_KT, _VT_co]) -> Self: ...
def __getitem__(self, __key: _KT) -> _VT_co: ...
def __getitem__(self, key: _KT, /) -> _VT_co: ...
def __iter__(self) -> Iterator[_KT]: ...
def __len__(self) -> int: ...
def __eq__(self, __value: object) -> bool: ...
def __eq__(self, value: object, /) -> bool: ...
def copy(self) -> dict[_KT, _VT_co]: ...
def keys(self) -> KeysView[_KT]: ...
def values(self) -> ValuesView[_VT_co]: ...
@@ -304,19 +307,19 @@ class MappingProxyType(Mapping[_KT, _VT_co]):
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
def __reversed__(self) -> Iterator[_KT]: ...
def __or__(self, __value: Mapping[_T1, _T2]) -> dict[_KT | _T1, _VT_co | _T2]: ...
def __ror__(self, __value: Mapping[_T1, _T2]) -> dict[_KT | _T1, _VT_co | _T2]: ...
def __or__(self, value: Mapping[_T1, _T2], /) -> dict[_KT | _T1, _VT_co | _T2]: ...
def __ror__(self, value: Mapping[_T1, _T2], /) -> dict[_KT | _T1, _VT_co | _T2]: ...
class SimpleNamespace:
__hash__: ClassVar[None] # type: ignore[assignment]
def __init__(self, **kwargs: Any) -> None: ...
def __eq__(self, __value: object) -> bool: ...
def __getattribute__(self, __name: str) -> Any: ...
def __setattr__(self, __name: str, __value: Any) -> None: ...
def __delattr__(self, __name: str) -> None: ...
def __eq__(self, value: object, /) -> bool: ...
def __getattribute__(self, name: str, /) -> Any: ...
def __setattr__(self, name: str, value: Any, /) -> None: ...
def __delattr__(self, name: str, /) -> None: ...
class _LoaderProtocol(Protocol):
def load_module(self, __fullname: str) -> ModuleType: ...
def load_module(self, fullname: str, /) -> ModuleType: ...
class ModuleType:
__name__: str
@@ -348,13 +351,13 @@ class GeneratorType(Generator[_YieldT_co, _SendT_contra, _ReturnT_co]):
__qualname__: str
def __iter__(self) -> Self: ...
def __next__(self) -> _YieldT_co: ...
def send(self, __arg: _SendT_contra) -> _YieldT_co: ...
def send(self, arg: _SendT_contra, /) -> _YieldT_co: ...
@overload
def throw(
self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...
self, typ: type[BaseException], val: BaseException | object = ..., tb: TracebackType | None = ..., /
) -> _YieldT_co: ...
@overload
def throw(self, __typ: BaseException, __val: None = None, __tb: TracebackType | None = ...) -> _YieldT_co: ...
def throw(self, typ: BaseException, val: None = None, tb: TracebackType | None = ..., /) -> _YieldT_co: ...
@final
class AsyncGeneratorType(AsyncGenerator[_YieldT_co, _SendT_contra]):
@@ -368,16 +371,16 @@ class AsyncGeneratorType(AsyncGenerator[_YieldT_co, _SendT_contra]):
def __aiter__(self) -> Self: ...
def __anext__(self) -> Coroutine[Any, Any, _YieldT_co]: ...
def asend(self, __val: _SendT_contra) -> Coroutine[Any, Any, _YieldT_co]: ...
def asend(self, val: _SendT_contra, /) -> Coroutine[Any, Any, _YieldT_co]: ...
@overload
async def athrow(
self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...
self, typ: type[BaseException], val: BaseException | object = ..., tb: TracebackType | None = ..., /
) -> _YieldT_co: ...
@overload
async def athrow(self, __typ: BaseException, __val: None = None, __tb: TracebackType | None = ...) -> _YieldT_co: ...
async def athrow(self, typ: BaseException, val: None = None, tb: TracebackType | None = ..., /) -> _YieldT_co: ...
def aclose(self) -> Coroutine[Any, Any, None]: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
@final
class CoroutineType(Coroutine[_YieldT_co, _SendT_contra, _ReturnT_co]):
@@ -391,13 +394,13 @@ class CoroutineType(Coroutine[_YieldT_co, _SendT_contra, _ReturnT_co]):
def close(self) -> None: ...
def __await__(self) -> Generator[Any, None, _ReturnT_co]: ...
def send(self, __arg: _SendT_contra) -> _YieldT_co: ...
def send(self, arg: _SendT_contra, /) -> _YieldT_co: ...
@overload
def throw(
self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...
self, typ: type[BaseException], val: BaseException | object = ..., tb: TracebackType | None = ..., /
) -> _YieldT_co: ...
@overload
def throw(self, __typ: BaseException, __val: None = None, __tb: TracebackType | None = ...) -> _YieldT_co: ...
def throw(self, typ: BaseException, val: None = None, tb: TracebackType | None = ..., /) -> _YieldT_co: ...
@final
class MethodType:
@@ -413,9 +416,9 @@ class MethodType:
def __name__(self) -> str: ... # inherited from the added function
@property
def __qualname__(self) -> str: ... # inherited from the added function
def __new__(cls, __func: Callable[..., Any], __obj: object) -> Self: ...
def __new__(cls, func: Callable[..., Any], obj: object, /) -> Self: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __eq__(self, __value: object) -> bool: ...
def __eq__(self, value: object, /) -> bool: ...
def __hash__(self) -> int: ...
@final
@@ -427,7 +430,7 @@ class BuiltinFunctionType:
@property
def __qualname__(self) -> str: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __eq__(self, __value: object) -> bool: ...
def __eq__(self, value: object, /) -> bool: ...
def __hash__(self) -> int: ...
BuiltinMethodType = BuiltinFunctionType
@@ -441,7 +444,7 @@ class WrapperDescriptorType:
@property
def __objclass__(self) -> type: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __get__(self, __instance: Any, __owner: type | None = None) -> Any: ...
def __get__(self, instance: Any, owner: type | None = None, /) -> Any: ...
@final
class MethodWrapperType:
@@ -454,8 +457,8 @@ class MethodWrapperType:
@property
def __objclass__(self) -> type: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __eq__(self, __value: object) -> bool: ...
def __ne__(self, __value: object) -> bool: ...
def __eq__(self, value: object, /) -> bool: ...
def __ne__(self, value: object, /) -> bool: ...
def __hash__(self) -> int: ...
@final
@@ -467,7 +470,7 @@ class MethodDescriptorType:
@property
def __objclass__(self) -> type: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __get__(self, __instance: Any, __owner: type | None = None) -> Any: ...
def __get__(self, instance: Any, owner: type | None = None, /) -> Any: ...
@final
class ClassMethodDescriptorType:
@@ -478,7 +481,7 @@ class ClassMethodDescriptorType:
@property
def __objclass__(self) -> type: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __get__(self, __instance: Any, __owner: type | None = None) -> Any: ...
def __get__(self, instance: Any, owner: type | None = None, /) -> Any: ...
@final
class TracebackType:
@@ -524,9 +527,9 @@ class GetSetDescriptorType:
def __qualname__(self) -> str: ...
@property
def __objclass__(self) -> type: ...
def __get__(self, __instance: Any, __owner: type | None = None) -> Any: ...
def __set__(self, __instance: Any, __value: Any) -> None: ...
def __delete__(self, __instance: Any) -> None: ...
def __get__(self, instance: Any, owner: type | None = None, /) -> Any: ...
def __set__(self, instance: Any, value: Any, /) -> None: ...
def __delete__(self, instance: Any, /) -> None: ...
@final
class MemberDescriptorType:
@@ -536,9 +539,9 @@ class MemberDescriptorType:
def __qualname__(self) -> str: ...
@property
def __objclass__(self) -> type: ...
def __get__(self, __instance: Any, __owner: type | None = None) -> Any: ...
def __set__(self, __instance: Any, __value: Any) -> None: ...
def __delete__(self, __instance: Any) -> None: ...
def __get__(self, instance: Any, owner: type | None = None, /) -> Any: ...
def __set__(self, instance: Any, value: Any, /) -> None: ...
def __delete__(self, instance: Any, /) -> None: ...
def new_class(
name: str,
@@ -552,7 +555,7 @@ def prepare_class(
) -> tuple[type, dict[str, Any], dict[str, Any]]: ...
if sys.version_info >= (3, 12):
def get_original_bases(__cls: type) -> tuple[Any, ...]: ...
def get_original_bases(cls: type, /) -> tuple[Any, ...]: ...
# Actually a different type, but `property` is special and we want that too.
DynamicClassAttribute = property
@@ -578,8 +581,8 @@ if sys.version_info >= (3, 9):
@property
def __parameters__(self) -> tuple[Any, ...]: ...
def __new__(cls, origin: type, args: Any) -> Self: ...
def __getitem__(self, __typeargs: Any) -> GenericAlias: ...
def __eq__(self, __value: object) -> bool: ...
def __getitem__(self, typeargs: Any, /) -> GenericAlias: ...
def __eq__(self, value: object, /) -> bool: ...
def __hash__(self) -> int: ...
if sys.version_info >= (3, 11):
@property
@@ -605,7 +608,7 @@ if sys.version_info >= (3, 10):
class UnionType:
@property
def __args__(self) -> tuple[Any, ...]: ...
def __or__(self, __value: Any) -> UnionType: ...
def __ror__(self, __value: Any) -> UnionType: ...
def __eq__(self, __value: object) -> bool: ...
def __or__(self, value: Any, /) -> UnionType: ...
def __ror__(self, value: Any, /) -> UnionType: ...
def __eq__(self, value: object, /) -> bool: ...
def __hash__(self) -> int: ...