8000 nested empty types not in to_dict · Issue #199 · danielgtaylor/python-betterproto · GitHub
[go: up one dir, main page]

Skip to content
nested empty types not in to_dict #199
@kilimnik

Description

@kilimnik

I am not sure if I am wrong here but when executing this:

from dataclasses import dataclass

import betterproto

@dataclass
class Inner(betterproto.Message):
    inner1: str = betterproto.string_field(1)
    inner2: str = betterproto.string_field(2)


@dataclass
class Test(betterproto.Message):
    name: str = betterproto.string_field(1)
    inner: "Inner" = betterproto.message_field(2)

test = Test(name='123', inner=Inner())
print(test.to_json())

I receive the output {"name": "123"}. I would expect the output to be{"name": "123", inner:{}}.
Of course there is a similar issue with the to_dict function

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0