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
Add documentation for __protobuf__ #244
Comments
Same question. Also, how should cross-package referencing work? For example: # composer.py
import proto
class Composer(proto.Message):
given_name = proto.Field(proto.STRING, number=1)
__protobuf__ = proto.module(package="composer", manifest={"Composer"}) # song.py
import proto
import composer
__protobuf__ = proto.module(package="song", manifest={"Song"})
class Song(proto.Message):
composer = proto.Field(composer.Composer, number=1) # __init__.py
import composer
import song
s = song.Song(composer=composer.Composer()) This will crash with
It does work with dicts and with In rule = self._rules.get(proto_type, self._noop)
return rule.to_python(value, absent=absent) Shouldn't this search take into account imported packages? |
For #244 (comment), the issue has been fixed in #348 |
It would be nice to have documentation on how to use the
__protobuf__ = proto.module
magic and what it actually does.I've seen it in use here:
https://github.com/googleapis/python-automl/blob/227c08b2fa6efa5af6677efc8e35382b23915fb4/google/cloud/automl_v1/types/classification.py#L19-L26
What is the
manifest
param for?It seems that nested messages do not need to be registered in there. Is that correct?
One problem I was facing: if you have two messages with the same name and no
__protobuf__
specified, you get an error:So I assume with
__protobuf__ = proto.module(package="a")
and__protobuf__ = proto.module(package="b")
you can somewhat define proto packages.The text was updated successfully, but these errors were encountered: