Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

tests: filter float_precision deprecation warning#548

Merged
parthea merged 1 commit intomainfrom
filter-float-precision-deprecated-warnings
Nov 19, 2025
Merged

tests: filter float_precision deprecation warning#548
parthea merged 1 commit intomainfrom
filter-float-precision-deprecated-warnings

Conversation

@parthea
Copy link
Copy Markdown
Contributor

@parthea parthea commented Nov 19, 2025

Without this PR, tests fail because warnings are treated as errors. See googleapis/google-cloud-python#15099 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

@parthea parthea requested a review from a team November 19, 2025 02:06
@parthea parthea enabled auto-merge (squash) November 19, 2025 02:07
@parthea parthea merged commit f3cda5c into main Nov 19, 2025
32 checks passed
@parthea parthea deleted the filter-float-precision-deprecated-warnings branch November 19, 2025 02:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants