justanr / marshmallow-annotations

Allows declaring marshmallow schema through type annotations
MIT License
48 stars 12 forks source link

Implement custom AnnotationSchema subclass for NamedTuple #12

Closed gwax closed 6 years ago

gwax commented 6 years ago

I started building out something very similar with a focus on supporting typing.NamedTuple as a central model construct. After stumbling on your project, it seemed easier to port my work to live on top of marshmallow-annotations than to try and roll my own parallel project.

justanr commented 6 years ago

👍 I'll have to take a closer look when I'm home from work but first glance looks good. Caught a few documentation errors too, appreciate that.

justanr commented 6 years ago

Being curious, how easy was this to implement? Is there anything that the library should do differently in your opinion?

gwax commented 6 years ago

This was pretty easy to implement because it mostly layered on top of what you had already done.

The converter portion took a little thinking but was totally reasonable.

Looking at #11, I think it will be pretty easy to abstract a few pieces of this code and add support for the Python 3.6 dataclasses backport. In anticipation of that, I might rearrange this and move marshmallow_annotations.namedtuple to marshmallow_annotations.ext.namedtuple.

gwax commented 6 years ago

I have moved the core default handling functionality into BaseConverter, put default value stripping behind a Meta option flag, and moved the namedtuple code to marshmallow_annotations.ext.

I think this is good to go now.

coveralls commented 6 years ago

Pull Request Test Coverage Report for Build 69


Totals Coverage Status
Change from base Build 64: 0.0%
Covered Lines: 217
Relevant Lines: 217

💛 - Coveralls
gwax commented 6 years ago

I believe that I have addressed your feedback.

justanr commented 6 years ago

:+1:

justanr commented 6 years ago

:beers: Just released 2.1.0 with this. Figured you wanted to use it in something so might as well make it easy to use.