-
Notifications
You must be signed in to change notification settings - Fork 1.6k
chore(migration): Migrate code from googleapis/proto-plus-python into packages/proto-plus #14921
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
Draft
parthea
wants to merge
273
commits into
main
Choose a base branch
from
migration.proto-plus-python.migration.2025-11-24_21-55-24.migrate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
chore(migration): Migrate code from googleapis/proto-plus-python into packages/proto-plus #14921
parthea
wants to merge
273
commits into
main
from
migration.proto-plus-python.migration.2025-11-24_21-55-24.migrate
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
Due to popular demand, proto3 recently added the concept of field presence. Fields can be marked as 'optional', which is internally represented via a synthetic oneof. See https://github.com/protocolbuffers/protobuf/releases/tag/v3.12.0 for additional background and information. Generated messages can define optional fields, and message classes gain constants that can be used to check for field presence in instances. These constants are not visible to message instances and therefore don't collide with message field names. Fields can be set as 'optional' using the following syntax Example: class Squid(proto.Message): mantle = proto.Field(proto.INT32, number=1, optional=True) s = Squid() assert not Squid.mantle in s s.mantle = 2112 assert Squid.mantle in s
…ision. (#40) Ports pieces of https://github.com/googleapis/python-api-core/blob/5e5559202891f7e5b6c22c2cbc549e1ec26eb857/google/api_core/datetime_helpers.py to protoplus. Particularly, a datetime implementation that provides nanoseconds. Fixes #38
* fix: Modify setup.py to indicate this is google maintained * fix: add 3.8 trove
* created CHANGELOG.md [ci skip] * updated setup.py * Update CHANGELOG.md Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Dov Shlachter <[email protected]>
* updated CHANGELOG.md [ci skip] * updated setup.py Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* updated CHANGELOG.md [ci skip] * updated setup.py Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* feat: prevent unnecessary copies when deserializing proto * Update message.py * Tweak json deserialization
* updated CHANGELOG.md [ci skip] * updated setup.py Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Add documentation for JSON serialization/deserialization Add documentation for making optional fields and determining field presence.
* chore: updated CHANGELOG.md [ci skip] * chore: updated setup.py Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* chore: updated CHANGELOG.md [ci skip] * chore: updated setup.py Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
… registry tools (#61) Salt is classname in lowercase when not declared in manifest. If manifest declared but class not in there a warning is issued to the log. Co-authored-by: Jon Court <[email protected]> Co-authored-by: Dov Shlachter <[email protected]>
* chore: updated CHANGELOG.md [ci skip] * chore: updated setup.py Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* chore: updated CHANGELOG.md [ci skip] * chore: updated setup.py Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Source-Link: googleapis/synthtool@bef813d Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:94bb690db96e6242b2567a4860a94d48fa48696d092e51b0884a1a2c0a79a407 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
* build(python): release script update Source-Link: googleapis/synthtool@71a7297 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:e8dcfd7cbfd8beac3a3ff8d3f3185287ea0625d859168cc80faccfc9a7a00455 * see googleapis/synthtool#2008 --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
* fix: fix 'Couldn't build proto file' when using Python 3.13 * fix: fix 'Couldn't build proto file' when using Python 3.13 * add comment
* feat: Add support for Python 3.13 * update python version for prerelease_deps
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* chore: update templated files * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
* chore: update templated files * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
* chore(python): update dependencies in .kokoro/docker/docs Source-Link: googleapis/synthtool@59171c8 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:2ed982f884312e4883e01b5ab8af8b6935f0216a5a2d82928d273081fc3be562 * See https://github.com/googleapis/synthtool/pull/2033/files --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
#511) * chore(python): Update the python version in docs presubmit to use 3.10 Source-Link: googleapis/synthtool@de3def6 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:a1c5112b81d645f5bbc4d4bbc99d7dcb5089a52216c0e3fb1203a0eeabadd7d5 * fix docs build --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
* fix: construct messages with nested duration in protobuf 5.28+ * Valueerror -> ValueError Co-authored-by: Victor Chudnovsky <[email protected]> * Use public issue links Co-authored-by: Victor Chudnovsky <[email protected]> * rename variables in test --------- Co-authored-by: Victor Chudnovsky <[email protected]>
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`. Co-authored-by: Anthonios Partheniou <[email protected]>
Source-Link: googleapis/synthtool@bd9ede2 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:04c35dc5f49f0f503a306397d6d043685f8d2bb822ab515818c4208d7fb2db3a Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
The old `intersphinx_mapping` format has been removed; it must now map identifiers to (target, inventory) tuples. Co-authored-by: Anthonios Partheniou <[email protected]>
…tup.py (#502) https://setuptools.pypa.io/en/latest/userguide/package_discovery.html has a warning: > Please have in mind that find_namespace: (setup.cfg), > find_namespace_packages() (setup.py) and find (pyproject.toml) > will scan all folders that you have in your project directory > if you use a flat-layout. That applies here. Without this change, if you run: 'python3 setup.py bdist_wheel' then you may end up with build/ in your wheel, and in some cases even docs/ and testing/ . The fix is to only include proto and proto.*. Signed-off-by: Scott Moser <[email protected]> Co-authored-by: Anthonios Partheniou <[email protected]>
* migrate to pyproject.toml * Rebase following googleapis/proto-plus-python#502 * add entries such as documentation and classifiers which exist in other projects * Use correct url for docs --------- Co-authored-by: Anthonios Partheniou <[email protected]>
* fix: enums initialization in PyPy When removing the _pb_options name from the enum attributes, enums initialization in PyPy should not raise exception. Refs: #506 * test: add presubmit for PyPy * Add unit (pypy3.10, python) as a required check --------- Co-authored-by: Anthonios Partheniou <[email protected]>
* chore: add presubmit for linting setup.py * fix duplicate implicit target name in README.rst * add action to lint setup.py * style * add new line
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
* fix(deps): allow protobuf 6.x * Remove 'dev'
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* build: remove unused scripts * disable owlbot --------- Co-authored-by: ohmayr <[email protected]>
Without this PR, tests fail because warnings are treated as errors. See googleapis/proto-plus-python#547 for follow up work related to the warning. ``` ________________________________________________________________________________________________________________________ test_serialize_to_dict_float_precision __________________________________________________________________________________________________________________________ def test_serialize_to_dict_float_precision(): class Squid(proto.Message): mass_kg = proto.Field(proto.FLOAT, number=1) s = Squid(mass_kg=3.14159265) > s_dict = Squid.to_dict(s, float_precision=3) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_message.py:336: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ proto/message.py:610: in to_dict return MessageToDict( .nox/unit-3-13-implementation-upb/lib/python3.13/site-packages/google/protobuf/json_format.py:158: in MessageToDict printer = _Printer( _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <google.protobuf.json_format._Printer object at 0x7fb6d1f15940>, preserving_proto_field_name = True, use_integers_for_enums = True, descriptor_pool = None, float_precision = 3, always_print_fields_with_no_presence = True def __init__( self, preserving_proto_field_name=False, use_integers_for_enums=False, descriptor_pool=None, float_precision=None, always_print_fields_with_no_presence=False, ): self.always_print_fields_with_no_presence = ( always_print_fields_with_no_presence ) self.preserving_proto_field_name = preserving_proto_field_name self.use_integers_for_enums = use_integers_for_enums self.descriptor_pool = descriptor_pool if float_precision: > warnings.warn( 'float_precision option is deprecated for json_format. ' 'This will turn into error in 7.34.0, please remove it ' 'before that.' ) E UserWarning: float_precision option is deprecated for json_format. This will turn into error in 7.34.0, please remove it before that. .nox/unit-3-13-implementation-upb/lib/python3.13/site-packages/google/protobuf/json_format.py:195: UserWarning ```
…n' into migration.proto-plus-python.migration.2025-11-24_21-55-24.migrate
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.
See #14906.
This PR should be merged with a merge-commit, not a squash-commit, in order to preserve the git history.