[Aio Type Hints] Update type hints for async iteration (#32655)

Fix python type hints for async iteration on `UnaryStreamCall` and
`StreamStreamCall`. Those classes _are_ `AsyncIterable`s and `__aiter__`
returns an `AsyncIterator`.


<!--

If you know who should review your pull request, please assign it to
that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the
appropriate
lang label.

-->
pull/32814/head
ryan-gunderson 2 years ago committed by GitHub
parent be99673d06
commit b58963c66a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      src/python/grpcio/grpc/aio/_base_call.py

@ -20,7 +20,7 @@ RPC, e.g. cancellation.
from abc import ABCMeta from abc import ABCMeta
from abc import abstractmethod from abc import abstractmethod
from typing import AsyncIterable, Awaitable, Generic, Optional, Union from typing import AsyncIterator, Awaitable, Generic, Optional, Union
import grpc import grpc
@ -154,13 +154,13 @@ class UnaryStreamCall(Generic[RequestType, ResponseType],
metaclass=ABCMeta): metaclass=ABCMeta):
@abstractmethod @abstractmethod
def __aiter__(self) -> AsyncIterable[ResponseType]: def __aiter__(self) -> AsyncIterator[ResponseType]:
"""Returns the async iterable representation that yields messages. """Returns the async iterator representation that yields messages.
Under the hood, it is calling the "read" method. Under the hood, it is calling the "read" method.
Returns: Returns:
An async iterable object that yields messages. An async iterator object that yields messages.
""" """
@abstractmethod @abstractmethod
@ -210,13 +210,13 @@ class StreamStreamCall(Generic[RequestType, ResponseType],
metaclass=ABCMeta): metaclass=ABCMeta):
@abstractmethod @abstractmethod
def __aiter__(self) -> AsyncIterable[ResponseType]: def __aiter__(self) -> AsyncIterator[ResponseType]:
"""Returns the async iterable representation that yields messages. """Returns the async iterator representation that yields messages.
Under the hood, it is calling the "read" method. Under the hood, it is calling the "read" method.
Returns: Returns:
An async iterable object that yields messages. An async iterator object that yields messages.
""" """
@abstractmethod @abstractmethod

Loading…
Cancel
Save