| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
I originally included a regression test, but I saw the comments made on other PRs around performance considerations of adding tests so I opted to remove it. See it below for reference: # Regression test for the AioRpcError.trailing_metadata() override: it must
# return the async grpc.aio.Metadata (iterating as (key, value) tuples), not the
# synchronous tuple[_Metadatum, ...] inherited from grpc.RpcError.
def check_aio_rpc_error_trailing_metadata(error: grpc.aio.AioRpcError) -> None:
assert_type(error.trailing_metadata(), grpc.aio.Metadata)
for key, value in error.trailing_metadata():
assert_type(key, str)
assert_type(value, grpc.aio._MetadataValue) |
Sorry, something went wrong.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks! For future reference: Please don't squash commits as it makes it harder to review. We squash on merge anyway.
Sorry, something went wrong.
|
Apologies, will do 👍. Thanks for merging. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
I encountered a typing issue when using grpc.aio and figured I would write a PR to solve it at source.
Two related fixes to the async (grpc.aio) metadata types:
AioRpcError.trailing_metadata() inherited the synchronous
RpcError.trailing_metadata() -> tuple[_Metadatum, ...], but at runtime returns a
grpc.aio.Metadata
(_call.py).
Added the override.
grpc.aio.Metadata was modelled as a Mapping, but the runtime class is a
Collection that iterates (key, value) tuples
(_metadata.py).
Re-based on Collection[_MetadatumType] with an item-yielding __iter__; keyed
access (m[key], m.get(...)) is unchanged.
Together these let for key, value in err.trailing_metadata() type-check — it
previously errored with "_Metadatum is not iterable".
Please let me know if I've overlooked something in the contribution process.