11import abc
22import asyncio
3- from _typeshed import Incomplete
4- from collections .abc import AsyncIterable , AsyncIterator , Awaitable , Callable , Generator , Iterable , Iterator , Mapping , Sequence
3+ from _typeshed import Incomplete , MaybeNone
4+ from collections .abc import (
5+ AsyncIterable ,
6+ AsyncIterator ,
7+ Awaitable ,
8+ Callable ,
9+ Collection ,
10+ Generator ,
11+ Iterable ,
12+ Iterator ,
13+ Mapping ,
14+ Sequence ,
15+ )
516from concurrent import futures
617from types import TracebackType
718from typing import Any , Generic , NoReturn , TypeAlias , TypeVar , overload , type_check_only
@@ -41,7 +52,10 @@ class AioRpcError(RpcError):
4152 debug_error_string : str | None = None ,
4253 ) -> None : ...
4354 def debug_error_string (self ) -> str : ...
44- def initial_metadata (self ) -> Metadata : ...
55+ def initial_metadata (self ) -> Metadata | MaybeNone : ...
56+ # AioRpcError returns the async Metadata, overriding the synchronous
57+ # grpc.RpcError.trailing_metadata() -> tuple[_Metadatum, ...].
58+ def trailing_metadata (self ) -> Metadata | MaybeNone : ... # type: ignore[override]
4559
4660# Create Client:
4761
@@ -445,7 +459,7 @@ _MetadatumType: TypeAlias = tuple[_MetadataKey, _MetadataValue]
445459_MetadataType : TypeAlias = Metadata | Sequence [_MetadatumType ]
446460_T = TypeVar ("_T" )
447461
448- class Metadata (Mapping [ _MetadataKey , _MetadataValue ]):
462+ class Metadata (Collection [ _MetadatumType ]):
449463 def __init__ (self , * args : tuple [_MetadataKey , _MetadataValue ]) -> None : ...
450464 @classmethod
451465 def from_tuple (cls , raw_metadata : tuple [_MetadataKey , _MetadataValue ]) -> Metadata : ...
@@ -455,7 +469,7 @@ class Metadata(Mapping[_MetadataKey, _MetadataValue]):
455469 def __setitem__ (self , key : _MetadataKey , value : _MetadataValue ) -> None : ...
456470 def __delitem__ (self , key : _MetadataKey ) -> None : ...
457471 def delete_all (self , key : _MetadataKey ) -> None : ...
458- def __iter__ (self ) -> Iterator [_MetadataKey ]: ...
472+ def __iter__ (self ) -> Iterator [_MetadatumType ]: ...
459473
460474 @overload
461475 def get (self , key : _MetadataKey , default : None = None ) -> _MetadataValue | None : ...
0 commit comments