Skip to content

Struct().from_dict(...) has no effect #549

Closed as not planned
Closed as not planned
@woodruffw

Description

@woodruffw

Summary

protobuf.Struct appears to not load correctly with from_dict(...), which also affects from_json(...)

Reproduction Steps

I originally saw this with a more complex message, however I've minified it down to a single API call.

Using betterproto==2.0.0b6:

>>> import betterproto.lib.google.protobuf as protobuf
>>> protobuf.Struct().from_dict({"a": "b"})

Expected Results

I expect a Struct instance populated from the dictionary:

Struct(a="b")

Actual Results

I receive an empty Struct instance:

Struct()

System Information

libprotoc 25.1
Python 3.12.0
Name: betterproto
Version: 2.0.0b6
Summary: A better Protobuf / gRPC generator & library
Home-page: https://github.com/danielgtaylor/python-betterproto
Author: Daniel G. Taylor
Author-email: danielgtaylor@gmail.com
License: MIT
Location: /Users/william/devel/attestation/python/env/lib/python3.12/site-packages
Requires: grpclib, python-dateutil
Required-by: in-toto-attestation

Checklist

  • I have searched the issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have verified this issue occurs on the latest prelease of betterproto which can be installed using pip install -U --pre betterproto, if possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions