-
Notifications
You must be signed in to change notification settings - Fork 10.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python asyncio servicer context invocation_metadata returns a tuple instead of Metadata #36613
Comments
Thanks for pointing this out! This does indeed seem to be an unintentional discrepancy. In order to minimize the impact of a fix here, I think the right thing to do is to change the type to match the implementation rather than the other way around. |
That's definitely a bit of a bummer. But makes sense. It would be quite the breaking change to change the return type. Is there any precedence for adding a differently named method that returns metadata, or as a fuction parameter. |
No precedent, but it's definitely something that could be discussed. We verbally discussed something like |
Its a lot of effort for something that can be fixed with a one-liner turning it into metadata again. I think fixing the typing would solve 90% of the problem |
Was about to report this issue as well. Yes I agree with @gnossen that I wouldn't want to see a fix that changes the return type, as it'd break the current code base I have (which I do |
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](#36613) Closes #36894 COPYBARA_INTEGRATE_REVIEW=#36894 from sreenithi:fix-issues/36613 7d3a047 PiperOrigin-RevId: 645276778
the above PR should have updated the invocation_metadata() return type. Hence closing the issue |
What version of gRPC and what language are you using?
Python 3.11 grpcio 1.63.0
What operating system (Linux, Windows,...) and version?
OSX 10.14
What runtime / compiler are you using (e.g. python version or version of gcc)
3.11
What did you do?
Created a python asyncio server. Called
invocation_metadata
and had atuple
returnedWhat did you expect to see?
invocation_metadata
to return agrpc.aio.Metadata
object like the type hint suggestsThe text was updated successfully, but these errors were encountered: