Skip to content

de: dataclasses: improve compatibility with non-standard dataclasses - #132

Open
Finomnis wants to merge 2 commits into
davidhewitt:mainfrom
Finomnis:dataclass_slots
Open

Finomnis wants to merge 2 commits into
davidhewitt:mainfrom
Finomnis:dataclass_slots

Conversation

@Finomnis

@Finomnis Finomnis commented Nov 26, 2026 •

Copy link
Copy Markdown

Rewrite dataclass deserialization to be more robust

  • use dataclasses.fields() instead of __dict__ as not all dataclasses offer __dict__
  • don't use __dataclass_fields__ as it seems to contain extra members that would have to get filtered out

So in python pseudocode, the rewrite pretty much does {field.name: getattr(obj, field.name) for field in fields(obj)}

@davidhewitt

Copy link
Copy Markdown
Owner

Thanks, this looks good to me but needs updating from main to fix the lint error. There's also a new unused import warning.

@Finomnis

Finomnis commented Dec 2, 2026

Copy link
Copy Markdown
Author

@davidhewitt Rebased to new main

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants