mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
Rename Generator-like type params to be more obvious (#10330)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
committed by
GitHub
parent
06c2fb047a
commit
4cfc49882e
@@ -17,7 +17,7 @@ from importlib.machinery import ModuleSpec
|
||||
|
||||
# pytype crashes if types.MappingProxyType inherits from collections.abc.Mapping instead of typing.Mapping
|
||||
from typing import Any, ClassVar, Generic, Mapping, Protocol, TypeVar, overload # noqa: Y022
|
||||
from typing_extensions import Literal, ParamSpec, TypeVarTuple, final
|
||||
from typing_extensions import Literal, ParamSpec, Self, TypeVarTuple, final
|
||||
|
||||
__all__ = [
|
||||
"FunctionType",
|
||||
@@ -63,11 +63,8 @@ if sys.version_info >= (3, 12):
|
||||
|
||||
_T1 = TypeVar("_T1")
|
||||
_T2 = TypeVar("_T2")
|
||||
_T_co = TypeVar("_T_co", covariant=True)
|
||||
_T_contra = TypeVar("_T_contra", contravariant=True)
|
||||
_KT = TypeVar("_KT")
|
||||
_VT_co = TypeVar("_VT_co", covariant=True)
|
||||
_V_co = TypeVar("_V_co", covariant=True)
|
||||
|
||||
@final
|
||||
class _Cell:
|
||||
@@ -351,27 +348,31 @@ class ModuleType:
|
||||
# using `builtins.__import__` or `importlib.import_module` less painful
|
||||
def __getattr__(self, name: str) -> Any: ...
|
||||
|
||||
_YieldT_co = TypeVar("_YieldT_co", covariant=True)
|
||||
_SendT_contra = TypeVar("_SendT_contra", contravariant=True)
|
||||
_ReturnT_co = TypeVar("_ReturnT_co", covariant=True)
|
||||
|
||||
@final
|
||||
class GeneratorType(Generator[_T_co, _T_contra, _V_co]):
|
||||
class GeneratorType(Generator[_YieldT_co, _SendT_contra, _ReturnT_co]):
|
||||
@property
|
||||
def gi_yieldfrom(self) -> GeneratorType[_T_co, _T_contra, Any] | None: ...
|
||||
def gi_yieldfrom(self) -> GeneratorType[_YieldT_co, _SendT_contra, Any] | None: ...
|
||||
if sys.version_info >= (3, 11):
|
||||
@property
|
||||
def gi_suspended(self) -> bool: ...
|
||||
__name__: str
|
||||
__qualname__: str
|
||||
def __iter__(self) -> GeneratorType[_T_co, _T_contra, _V_co]: ...
|
||||
def __next__(self) -> _T_co: ...
|
||||
def send(self, __arg: _T_contra) -> _T_co: ...
|
||||
def __iter__(self) -> Self: ...
|
||||
def __next__(self) -> _YieldT_co: ...
|
||||
def send(self, __arg: _SendT_contra) -> _YieldT_co: ...
|
||||
@overload
|
||||
def throw(
|
||||
self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...
|
||||
) -> _T_co: ...
|
||||
) -> _YieldT_co: ...
|
||||
@overload
|
||||
def throw(self, __typ: BaseException, __val: None = None, __tb: TracebackType | None = ...) -> _T_co: ...
|
||||
def throw(self, __typ: BaseException, __val: None = None, __tb: TracebackType | None = ...) -> _YieldT_co: ...
|
||||
|
||||
@final
|
||||
class AsyncGeneratorType(AsyncGenerator[_T_co, _T_contra]):
|
||||
class AsyncGeneratorType(AsyncGenerator[_YieldT_co, _SendT_contra]):
|
||||
@property
|
||||
def ag_await(self) -> Awaitable[Any] | None: ...
|
||||
__name__: str
|
||||
@@ -380,21 +381,21 @@ class AsyncGeneratorType(AsyncGenerator[_T_co, _T_contra]):
|
||||
@property
|
||||
def ag_suspended(self) -> bool: ...
|
||||
|
||||
def __aiter__(self) -> AsyncGeneratorType[_T_co, _T_contra]: ...
|
||||
def __anext__(self) -> Coroutine[Any, Any, _T_co]: ...
|
||||
def asend(self, __val: _T_contra) -> Coroutine[Any, Any, _T_co]: ...
|
||||
def __aiter__(self) -> Self: ...
|
||||
def __anext__(self) -> 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 = ...
|
||||
) -> _T_co: ...
|
||||
) -> _YieldT_co: ...
|
||||
@overload
|
||||
async def athrow(self, __typ: BaseException, __val: None = None, __tb: TracebackType | None = ...) -> _T_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: ...
|
||||
|
||||
@final
|
||||
class CoroutineType(Coroutine[_T_co, _T_contra, _V_co]):
|
||||
class CoroutineType(Coroutine[_YieldT_co, _SendT_contra, _ReturnT_co]):
|
||||
__name__: str
|
||||
__qualname__: str
|
||||
@property
|
||||
@@ -404,14 +405,14 @@ class CoroutineType(Coroutine[_T_co, _T_contra, _V_co]):
|
||||
def cr_suspended(self) -> bool: ...
|
||||
|
||||
def close(self) -> None: ...
|
||||
def __await__(self) -> Generator[Any, None, _V_co]: ...
|
||||
def send(self, __arg: _T_contra) -> _T_co: ...
|
||||
def __await__(self) -> Generator[Any, None, _ReturnT_co]: ...
|
||||
def send(self, __arg: _SendT_contra) -> _YieldT_co: ...
|
||||
@overload
|
||||
def throw(
|
||||
self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...
|
||||
) -> _T_co: ...
|
||||
) -> _YieldT_co: ...
|
||||
@overload
|
||||
def throw(self, __typ: BaseException, __val: None = None, __tb: TracebackType | None = ...) -> _T_co: ...
|
||||
def throw(self, __typ: BaseException, __val: None = None, __tb: TracebackType | None = ...) -> _YieldT_co: ...
|
||||
|
||||
class _StaticFunctionType:
|
||||
# Fictional type to correct the type of MethodType.__func__.
|
||||
|
||||
Reference in New Issue
Block a user