Skip to content

Conversation

@daniel-sanche
Copy link

Fixes googleapis/google-cloud-python#15099

Protobuf 7 is removing the float_prevision argument. This PR ignores it when passed in 7.x+, and raises a DeprecationWarning

@daniel-sanche daniel-sanche requested a review from a team as a code owner January 24, 2026 00:51
@gemini-code-assist
Copy link

Summary of Changes

Hello @daniel-sanche, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request updates the library to gracefully manage the breaking change introduced in Protobuf 7, where the float_precision argument was removed. It ensures that the library remains functional across different Protobuf versions by dynamically adapting its behavior based on the detected Protobuf major version, providing a clear deprecation warning for users who might still be passing the removed argument.

Highlights

  • Protobuf 7 Compatibility: The pull request introduces changes to ensure compatibility with Protobuf version 7, specifically addressing the removal of the float_precision argument.
  • Version Detection: A mechanism has been added to proto/message.py to extract and store the major version of the installed Protobuf library, allowing for version-specific logic.
  • Conditional Argument Handling: The to_json and to_dict methods now conditionally handle the float_precision argument. For Protobuf versions 3-6, it is passed through, but for Protobuf 7+, it is ignored.
  • Deprecation Warning: When float_precision is provided in calls to to_json or to_dict while running on Protobuf 7 or higher, a DeprecationWarning is now issued to inform users of its removal.
  • Code Refactoring: Common logic for to_json and to_dict has been extracted into a new private helper function _message_to_map to reduce code duplication and centralize version-dependent argument handling.
  • Test Coverage: New tests have been added to tests/test_json.py and tests/test_message.py to specifically verify the behavior of float_precision with Protobuf 7+, including the emission of the DeprecationWarning.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly addresses the removal of the float_precision argument in Protobuf 7. The approach of ignoring the argument and issuing a DeprecationWarning for newer versions is sound. The refactoring of to_json and to_dict into a shared helper function is a good improvement for code maintainability. I have one minor suggestion to simplify the logic for extracting the Protobuf major version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate float_precision argument

1 participant