-
Notifications
You must be signed in to change notification settings - Fork 37
fix: incorrect return type annotation for Message.to_dict #516
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
Merged
parthea
merged 2 commits into
googleapis:main
from
bricker:bcr/2501/fix-to_dict-return-type
Jan 21, 2025
Merged
fix: incorrect return type annotation for Message.to_dict #516
parthea
merged 2 commits into
googleapis:main
from
bricker:bcr/2501/fix-to_dict-return-type
Jan 21, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d57772a
to
08b9f85
Compare
Tests with Python 3.9 pass but Python 3.8 fails. We'll wait to merge this PR until Python 3.8 is dropped which I expect will be this quarter. Thank you for the fix @bricker ! We'll get this merged soon.
|
|
parthea
reviewed
Jan 17, 2025
The `proto.Message.to_dict` function returns a `dict[str, Any]`, but its return type annotation is incorrectly set to `Message`. The `proto.Message.to_dict` function returns the result of calling [`google.protobuf.json_format.MessageToDict()`](https://github.com/protocolbuffers/protobuf/blob/c58621b6ff2e6145ffb14c7e5a7af7648dfc0535/python/google/protobuf/json_format.py#L125-L162), which returns `dict[str, Any]` as specified in the [protobuf typeshed stubs](https://github.com/python/typeshed/blob/main/stubs/protobuf/google/protobuf/json_format.pyi#L23-L30). Additionally, runtime introspection shows that the function returns a `dict`.
08b9f85
to
d8f7f1a
Compare
parthea
approved these changes
Jan 21, 2025
Thanks @bricker ! |
This was referenced Jan 22, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
proto.Message.to_dict
function returns adict[str, Any]
, but its return type annotation is incorrectly set toMessage
.The
proto.Message.to_dict
function returns the result of callinggoogle.protobuf.json_format.MessageToDict()
, which returnsdict[str, Any]
as specified in the protobuf typeshed stubs.Additionally, runtime introspection shows that the function returns a
dict
.Fixes #489