-
Notifications
You must be signed in to change notification settings - Fork 37
Closed
Labels
priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
Currently calling Message.to_dict(my_message) and it is correctly returning a dictionary. However the my type checker is throwing errors downstream because it thinks it is a Message object instead of a python dict.
After looking through the source i found that the to_dict return type annotation is a Message:
def to_dict(
cls,
instance,
*,
use_integers_for_enums=True,
preserving_proto_field_name=True,
including_default_value_fields=None,
float_precision=None,
always_print_fields_with_no_presence=None,
) -> "Message":
"""Given a message instance, return its representation as a python dict.
However, the to_json method it is correctly typed as a str:
def to_json(
cls,
instance,
*,
use_integers_for_enums=True,
including_default_value_fields=None,
preserving_proto_field_name=False,
sort_keys=False,
indent=2,
float_precision=None,
always_print_fields_with_no_presence=None,
) -> str:
Wondering if this is the intended implementation?
bricker and aabmass
Metadata
Metadata
Assignees
Labels
priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.