Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: support for Python 3.7 data classes #43

Closed
anthrotype opened this issue Sep 23, 2018 · 10 comments
Closed

feature request: support for Python 3.7 data classes #43

anthrotype opened this issue Sep 23, 2018 · 10 comments

Comments

@anthrotype
Copy link

anthrotype commented Sep 23, 2018

Would it be desirable/feasible to extend cattrs deserialization/serialization support to Python 3.7 Data Classes?
Or is it out of scope?
Thanks for this great little library.

@Tinche
Copy link
Member

Tinche commented Sep 27, 2018

Definitely something we should look at supporting eventually. And it shouldn't be difficult, since they are basically a subset of attrs.

@petergaultney
Copy link
Contributor

Is this still under consideration? I'd be up for looking into it and seeing if I couldn't make a PR.

@ClaireNeveu
Copy link

@Tinche If you're willing to have this functionality I'd be happy to make a PR for it. I have existing code for this that I think would be fairly easy to integrate upstream.

@Tinche
Copy link
Member

Tinche commented Feb 22, 2021

Sure. I would start by mimicking what the GenConverter does to generate functions for attrs classes, just for dataclasses.

@asford
Copy link
Contributor

asford commented Mar 16, 2021

@ClaireNeveu did you have a chance to look at your existing code and see if it'd be PR-able?
If you can find the time to open even a super rough draft PR I'd be happy to help tidy it up for testing and merge.
We've just run into this issue and would love to continue using cattrs on some dataclasses-based classes.

@Tinche
Copy link
Member

Tinche commented Mar 16, 2021

@asford I've put something together over at https://github.com/Tinche/cattrs/tree/tin/dataclasses. Want to try it out and see if it works for you?

@ClaireNeveu
Copy link

Ah, I did put something together but I've been pretty sick the past two weeks and haven't found time to PR it.

@asford
Copy link
Contributor

asford commented Mar 16, 2021

Thanks for the awesome responses.

@ClaireNeveu I hope you can take all the time you need to center on yourself and feel better. For what it's worth, a co-human-you've-probably-never-met-on-the-internet is sending well wishes.

@Tinche looks great so far! I suspected this was going to be pretty doable, but glad to see it's not a massive or disruptive change. The hypothesis-driven tests are a little outside my zone of expertise, so I opened a sub-PR with the basic cases I'm working with. It required a few, minor additional fixes to use the _compat interface that I haven't fully tested.

https://github.com/Tinche/cattrs/pull/134

@Tinche
Copy link
Member

Tinche commented Mar 21, 2021

Good news, this feature is essentially done! I expect to release it tomorrow.

@Tinche
Copy link
Member

Tinche commented Mar 21, 2021

Released as 1.4.0.

@Tinche Tinche closed this as completed Mar 21, 2021
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

No branches or pull requests

5 participants