msgspec icon indicating copy to clipboard operation
msgspec copied to clipboard

Stop skipping private fields for attrs classes

Open Tinche opened this issue 10 months ago • 1 comments

Description

Continuing our discussion from Bluesky, I would really like for msgspec to stop skipping fields prefixed with _ for attrs classes. This would make attrs classes consistent with dataclasses, and more importantly - enable handling APIs that require field names that start with underscores, which I find to not be super common, but definitely an important use case.

If this is simple, maybe I could contribute this?

Tinche avatar Jan 20 '25 09:01 Tinche

You can use field to define a custom name mapping between the underscore-prefixed API keys and Struct attributes: https://jcristharif.com/msgspec/api.html#msgspec.field

ipseitas avatar Jan 23 '25 23:01 ipseitas