mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +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
@@ -289,10 +289,8 @@ _S = TypeVar("_S")
|
||||
_KT = TypeVar("_KT") # Key type.
|
||||
_VT = TypeVar("_VT") # Value type.
|
||||
_T_co = TypeVar("_T_co", covariant=True) # Any type covariant containers.
|
||||
_V_co = TypeVar("_V_co", covariant=True) # Any type covariant containers.
|
||||
_KT_co = TypeVar("_KT_co", covariant=True) # Key type covariant containers.
|
||||
_VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers.
|
||||
_T_contra = TypeVar("_T_contra", contravariant=True) # Ditto contravariant.
|
||||
_TC = TypeVar("_TC", bound=Type[object])
|
||||
|
||||
def no_type_check(arg: _F) -> _F: ...
|
||||
@@ -397,20 +395,24 @@ class Reversible(Iterable[_T_co], Protocol[_T_co]):
|
||||
@abstractmethod
|
||||
def __reversed__(self) -> Iterator[_T_co]: ...
|
||||
|
||||
class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
|
||||
def __next__(self) -> _T_co: ...
|
||||
_YieldT_co = TypeVar("_YieldT_co", covariant=True)
|
||||
_SendT_contra = TypeVar("_SendT_contra", contravariant=True)
|
||||
_ReturnT_co = TypeVar("_ReturnT_co", covariant=True)
|
||||
|
||||
class Generator(Iterator[_YieldT_co], Generic[_YieldT_co, _SendT_contra, _ReturnT_co]):
|
||||
def __next__(self) -> _YieldT_co: ...
|
||||
@abstractmethod
|
||||
def send(self, __value: _T_contra) -> _T_co: ...
|
||||
def send(self, __value: _SendT_contra) -> _YieldT_co: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
def throw(
|
||||
self, __typ: Type[BaseException], __val: BaseException | object = None, __tb: TracebackType | None = None
|
||||
) -> _T_co: ...
|
||||
) -> _YieldT_co: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
def throw(self, __typ: BaseException, __val: None = None, __tb: TracebackType | None = None) -> _T_co: ...
|
||||
def throw(self, __typ: BaseException, __val: None = None, __tb: TracebackType | None = None) -> _YieldT_co: ...
|
||||
def close(self) -> None: ...
|
||||
def __iter__(self) -> Generator[_T_co, _T_contra, _V_co]: ...
|
||||
def __iter__(self) -> Generator[_YieldT_co, _SendT_contra, _ReturnT_co]: ...
|
||||
@property
|
||||
def gi_code(self) -> CodeType: ...
|
||||
@property
|
||||
@@ -425,7 +427,7 @@ class Awaitable(Protocol[_T_co]):
|
||||
@abstractmethod
|
||||
def __await__(self) -> Generator[Any, None, _T_co]: ...
|
||||
|
||||
class Coroutine(Awaitable[_V_co], Generic[_T_co, _T_contra, _V_co]):
|
||||
class Coroutine(Awaitable[_ReturnT_co], Generic[_YieldT_co, _SendT_contra, _ReturnT_co]):
|
||||
__name__: str
|
||||
__qualname__: str
|
||||
@property
|
||||
@@ -437,15 +439,15 @@ class Coroutine(Awaitable[_V_co], Generic[_T_co, _T_contra, _V_co]):
|
||||
@property
|
||||
def cr_running(self) -> bool: ...
|
||||
@abstractmethod
|
||||
def send(self, __value: _T_contra) -> _T_co: ...
|
||||
def send(self, __value: _SendT_contra) -> _YieldT_co: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
def throw(
|
||||
self, __typ: Type[BaseException], __val: BaseException | object = None, __tb: TracebackType | None = None
|
||||
) -> _T_co: ...
|
||||
) -> _YieldT_co: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
def throw(self, __typ: BaseException, __val: None = None, __tb: TracebackType | None = None) -> _T_co: ...
|
||||
def throw(self, __typ: BaseException, __val: None = None, __tb: TracebackType | None = None) -> _YieldT_co: ...
|
||||
@abstractmethod
|
||||
def close(self) -> None: ...
|
||||
|
||||
@@ -453,7 +455,10 @@ class Coroutine(Awaitable[_V_co], Generic[_T_co, _T_contra, _V_co]):
|
||||
# The parameters correspond to Generator, but the 4th is the original type.
|
||||
@type_check_only
|
||||
class AwaitableGenerator(
|
||||
Awaitable[_V_co], Generator[_T_co, _T_contra, _V_co], Generic[_T_co, _T_contra, _V_co, _S], metaclass=ABCMeta
|
||||
Awaitable[_ReturnT_co],
|
||||
Generator[_YieldT_co, _SendT_contra, _ReturnT_co],
|
||||
Generic[_YieldT_co, _SendT_contra, _ReturnT_co, _S],
|
||||
metaclass=ABCMeta,
|
||||
): ...
|
||||
|
||||
@runtime_checkable
|
||||
@@ -467,18 +472,18 @@ class AsyncIterator(AsyncIterable[_T_co], Protocol[_T_co]):
|
||||
def __anext__(self) -> Awaitable[_T_co]: ...
|
||||
def __aiter__(self) -> AsyncIterator[_T_co]: ...
|
||||
|
||||
class AsyncGenerator(AsyncIterator[_T_co], Generic[_T_co, _T_contra]):
|
||||
def __anext__(self) -> Awaitable[_T_co]: ...
|
||||
class AsyncGenerator(AsyncIterator[_YieldT_co], Generic[_YieldT_co, _SendT_contra]):
|
||||
def __anext__(self) -> Awaitable[_YieldT_co]: ...
|
||||
@abstractmethod
|
||||
def asend(self, __value: _T_contra) -> Awaitable[_T_co]: ...
|
||||
def asend(self, __value: _SendT_contra) -> Awaitable[_YieldT_co]: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
def athrow(
|
||||
self, __typ: Type[BaseException], __val: BaseException | object = None, __tb: TracebackType | None = None
|
||||
) -> Awaitable[_T_co]: ...
|
||||
) -> Awaitable[_YieldT_co]: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
def athrow(self, __typ: BaseException, __val: None = None, __tb: TracebackType | None = None) -> Awaitable[_T_co]: ...
|
||||
def athrow(self, __typ: BaseException, __val: None = None, __tb: TracebackType | None = None) -> Awaitable[_YieldT_co]: ...
|
||||
def aclose(self) -> Awaitable[None]: ...
|
||||
@property
|
||||
def ag_await(self) -> Any: ...
|
||||
|
||||
Reference in New Issue
Block a user