Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions stdlib/types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ class CellType:
cell_contents: Any

_YieldT_co = TypeVar("_YieldT_co", covariant=True)
_SendT_contra = TypeVar("_SendT_contra", contravariant=True)
_ReturnT_co = TypeVar("_ReturnT_co", covariant=True)
_SendT_contra = TypeVar("_SendT_contra", contravariant=True, default=None)
_ReturnT_co = TypeVar("_ReturnT_co", covariant=True, default=None)

@final
class GeneratorType(Generator[_YieldT_co, _SendT_contra, _ReturnT_co]):
Expand Down Expand Up @@ -450,8 +450,12 @@ class AsyncGeneratorType(AsyncGenerator[_YieldT_co, _SendT_contra]):
def aclose(self) -> Coroutine[Any, Any, None]: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...

# Non-default variations to accommodate coroutines
_SendT_nd_contra = TypeVar("_SendT_nd_contra", contravariant=True)
_ReturnT_nd_co = TypeVar("_ReturnT_nd_co", covariant=True)

@final
class CoroutineType(Coroutine[_YieldT_co, _SendT_contra, _ReturnT_co]):
class CoroutineType(Coroutine[_YieldT_co, _SendT_nd_contra, _ReturnT_nd_co]):
__name__: str
__qualname__: str
@property
Expand All @@ -469,8 +473,8 @@ class CoroutineType(Coroutine[_YieldT_co, _SendT_contra, _ReturnT_co]):
def cr_suspended(self) -> bool: ...

def close(self) -> None: ...
def __await__(self) -> Generator[Any, None, _ReturnT_co]: ...
def send(self, arg: _SendT_contra, /) -> _YieldT_co: ...
def __await__(self) -> Generator[Any, None, _ReturnT_nd_co]: ...
def send(self, arg: _SendT_nd_contra, /) -> _YieldT_co: ...
@overload
def throw(
self, typ: type[BaseException], val: BaseException | object = ..., tb: TracebackType | None = ..., /
Expand Down
2 changes: 1 addition & 1 deletion stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ class Awaitable(Protocol[_T_co]):
@abstractmethod
def __await__(self) -> Generator[Any, Any, _T_co]: ...

# Non-default variations to accommodate couroutines, and `AwaitableGenerator` having a 4th type parameter.
# Non-default variations to accommodate coroutines, and `AwaitableGenerator` having a 4th type parameter.
_SendT_nd_contra = TypeVar("_SendT_nd_contra", contravariant=True)
_ReturnT_nd_co = TypeVar("_ReturnT_nd_co", covariant=True)

Expand Down
Loading