dataclass-wizard
dataclass-wizard copied to clipboard
Support loading from attribute-based objects (from_attributes)
This issue tracks a possible enhancement discussed in #185.
Idea
Allow fromdict / loaders to support loading from attribute-based objects
(e.g. ORM models, SimpleNamespace, or custom objects), similar to a
from_attributes=True option.
Open questions
- What kinds of input objects should be supported?
- Should attribute access replace dict access, or act as a fallback?
- How should this interact with aliases and
AliasPath?
Proposed direction (tentative)
- Default behavior unchanged (mapping-only).
- Optional opt-in via
LoadMeta(from_attributes=True)or v1 equivalent. - If enabled and input is not a mapping, resolve values via
getattr.
Linked from discussion #185.