Skip to content

Cover omit_defaults handling in asdict and to_builtins documentation #778

Open
@ncoghlan

Description

Description

(I'm not sure if this is a bug report or a feature request, so I opted for a feature request in case the current behaviour is intentional)

I am using msgspec to help communicate with a server where a boolean field can be set to None in the data model not because null is a valid value, but because it is permitted to omit the key entirely. The relevant struct has omit_defaults=True set accordingly.

However, msgspec isn't handling the full message serialisation (httpx is doing that), so I attempted to use asdict to generate the message spec portion of the message.

This failed, as asdict includes all fields, without paying attention to omit_defaults.

Activity

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

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