Skip to content
Merged
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
6 changes: 2 additions & 4 deletions stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -603,10 +603,8 @@ class Awaitable(Protocol[_T_co]):
_SendT_nd_contra = TypeVar("_SendT_nd_contra", contravariant=True)
_ReturnT_nd_co = TypeVar("_ReturnT_nd_co", covariant=True)

class Coroutine(Awaitable[_ReturnT_nd_co], Generic[_YieldT_co, _SendT_nd_contra, _ReturnT_nd_co]):
__name__: str
__qualname__: str
Comment on lines -607 to -608

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these aren't required for an isinstance() check to pass at runtime, and I don't think __name__ or __qualname__ attributes are really relevant to the abstract idea of what it means for a nominal class (like types.CoroutineType) to be coroutine-like. So I don't think it's appropriate for them to be listed here.

types.CoroutineType, the concrete, nominal type returned by async def functions at runtime, should have these attributes, of course, and still does on this branch:

typeshed/stdlib/types.pyi

Lines 428 to 431 in 57035b1

@final
class CoroutineType(Coroutine[_YieldT_co, _SendT_nd_contra, _ReturnT_nd_co]):
__name__: str
__qualname__: str


@runtime_checkable
class Coroutine(Awaitable[_ReturnT_nd_co], Protocol[_YieldT_co, _SendT_nd_contra, _ReturnT_nd_co]):
@abstractmethod
def send(self, value: _SendT_nd_contra, /) -> _YieldT_co: ...

Expand Down
Loading