-
Notifications
You must be signed in to change notification settings - Fork 36
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
Message with message nested in map cannot be created with dict #161
Comments
Minimal reproducing type: class Boat(proto.Message):
class Net(proto.Message):
class Mollusc(proto.Message):
mass_kg = proto.Field(proto.INT32, number=1)
molluscs = proto.MapField(proto.STRING, Mollusc, number=1)
net = proto.Field(Net, number=1)
b = Boat(net={"molluscs": {"squid": {"mass_kg": 100}}}) # raises an exception Workaround is to explicitly use types, e.g. b = Boat(net=Boat.Net(molluscs={"squid": Boat.Net.Mollusc(mass_kg=20)})) |
@software-dov Do you have a sense of how easy/hard it would be to fix this? It seems natural for folks to mix mix dict/type instantiation (especially when the request object is big). |
@software-dov are there planes to address this issue? |
+1 |
I'm not able to reproduce this issue. Please open a new issue if you're still experiencing the problem.
Tested with
|
Generate the python GAPIC library with the following proto:
The resulting library cannot be used to create certain
Outer
messages:(1)
raises
TypeError: Parameter to MergeFrom() must be instance of same class: expected google.cloud.mypackage.Stuff got dict.
.(2)
raises
TypeError: Parameter to MergeFrom() must be instance of same class: expected google.cloud.mypackage.Stuff got Stuff.
.(3)
works fine, and builds:
The text was updated successfully, but these errors were encountered: