[Aio] Correct the typing of input Metadata (#27768)

pull/27767/head
Lidi Zheng 3 years ago committed by GitHub
parent 790ce5c97f
commit 2bc96189b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/python/grpcio/grpc/aio/_base_channel.py
  2. 8
      src/python/grpcio/grpc/aio/_base_server.py
  3. 2
      src/python/grpcio/grpc/aio/_typing.py

@ -19,8 +19,8 @@ from typing import Any, Optional
import grpc
from . import _base_call
from ._metadata import Metadata
from ._typing import DeserializingFunction
from ._typing import MetadataType
from ._typing import RequestIterableType
from ._typing import SerializingFunction
@ -34,7 +34,7 @@ class UnaryUnaryMultiCallable(abc.ABC):
request: Any,
*,
timeout: Optional[float] = None,
metadata: Optional[Metadata] = None,
metadata: Optional[MetadataType] = None,
credentials: Optional[grpc.CallCredentials] = None,
wait_for_ready: Optional[bool] = None,
compression: Optional[grpc.Compression] = None
@ -73,7 +73,7 @@ class UnaryStreamMultiCallable(abc.ABC):
request: Any,
*,
timeout: Optional[float] = None,
metadata: Optional[Metadata] = None,
metadata: Optional[MetadataType] = None,
credentials: Optional[grpc.CallCredentials] = None,
wait_for_ready: Optional[bool] = None,
compression: Optional[grpc.Compression] = None
@ -111,7 +111,7 @@ class StreamUnaryMultiCallable(abc.ABC):
self,
request_iterator: Optional[RequestIterableType] = None,
timeout: Optional[float] = None,
metadata: Optional[Metadata] = None,
metadata: Optional[MetadataType] = None,
credentials: Optional[grpc.CallCredentials] = None,
wait_for_ready: Optional[bool] = None,
compression: Optional[grpc.Compression] = None
@ -150,7 +150,7 @@ class StreamStreamMultiCallable(abc.ABC):
self,
request_iterator: Optional[RequestIterableType] = None,
timeout: Optional[float] = None,
metadata: Optional[Metadata] = None,
metadata: Optional[MetadataType] = None,
credentials: Optional[grpc.CallCredentials] = None,
wait_for_ready: Optional[bool] = None,
compression: Optional[grpc.Compression] = None

@ -19,6 +19,7 @@ from typing import Generic, Iterable, Mapping, Optional, Sequence
import grpc
from ._metadata import Metadata
from ._typing import MetadataType
from ._typing import RequestType
from ._typing import ResponseType
@ -159,7 +160,8 @@ class ServicerContext(Generic[RequestType, ResponseType], abc.ABC):
"""
@abc.abstractmethod
async def send_initial_metadata(self, initial_metadata: Metadata) -> None:
async def send_initial_metadata(self,
initial_metadata: MetadataType) -> None:
"""Sends the initial metadata value to the client.
This method need not be called by implementations if they have no
@ -174,7 +176,7 @@ class ServicerContext(Generic[RequestType, ResponseType], abc.ABC):
self,
code: grpc.StatusCode,
details: str = '',
trailing_metadata: Metadata = tuple()) -> None:
trailing_metadata: MetadataType = tuple()) -> None:
"""Raises an exception to terminate the RPC with a non-OK status.
The code and details passed as arguments will supercede any existing
@ -194,7 +196,7 @@ class ServicerContext(Generic[RequestType, ResponseType], abc.ABC):
"""
@abc.abstractmethod
def set_trailing_metadata(self, trailing_metadata: Metadata) -> None:
def set_trailing_metadata(self, trailing_metadata: MetadataType) -> None:
"""Sends the trailing metadata for the RPC.
This method need not be called by implementations if they have no

@ -27,7 +27,7 @@ ResponseType = TypeVar('ResponseType')
SerializingFunction = Callable[[Any], bytes]
DeserializingFunction = Callable[[bytes], Any]
MetadatumType = Tuple[MetadataKey, MetadataValue]
MetadataType = Metadata
MetadataType = Union[Metadata, Sequence[MetadatumType]]
ChannelArgumentType = Sequence[Tuple[str, Any]]
EOFType = type(EOF)
DoneCallbackType = Callable[[Any], None]

Loading…
Cancel
Save