From a98ac04feec634471b6f7d5a0035722378314335 Mon Sep 17 00:00:00 2001 From: Sreenithi Sridharan <19sreenithi98@gmail.com> Date: Thu, 20 Jun 2024 23:17:53 -0700 Subject: [PATCH] [fix] updated invocation_metadata return type hint (#36894) Updated the type hint for return type of grpc.aio.ServicerContext.invocation_metadata() to Optional[MetadataType] instead of Optional[Metadata]. MetadataType is already defined to be a Sequence[MetadatumType] and hence the type hint will reflect the sequence being returned, hence solving the [user's reported issue](https://github.com/grpc/grpc/issues/36613) Closes #36894 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36894 from sreenithi:fix-issues/36613 7d3a047309e7be85dc61384e1396d804c180fb0f PiperOrigin-RevId: 645276778 --- src/python/grpcio/grpc/aio/_base_server.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/python/grpcio/grpc/aio/_base_server.py b/src/python/grpcio/grpc/aio/_base_server.py index 6be8527b901..f09dee1fac4 100644 --- a/src/python/grpcio/grpc/aio/_base_server.py +++ b/src/python/grpcio/grpc/aio/_base_server.py @@ -18,7 +18,6 @@ from typing import Generic, Iterable, Mapping, NoReturn, Optional, Sequence import grpc -from ._metadata import Metadata from ._typing import DoneCallbackType from ._typing import MetadataType from ._typing import RequestType @@ -225,7 +224,7 @@ class ServicerContext(Generic[RequestType, ResponseType], abc.ABC): """ @abc.abstractmethod - def invocation_metadata(self) -> Optional[Metadata]: + def invocation_metadata(self) -> Optional[MetadataType]: """Accesses the metadata sent by the client. Returns: