Last active
April 5, 2019 12:19
-
-
Save mvantellingen/a879bd07d844519613493c9b91dd35ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import attr, marshmallow, typing | |
@attr.s(auto_attribs=True, init=False, repr=False) | |
class Price: | |
id: typing.Optional[str] | |
def __init__(self, *, id: typing.Optional[str] = None) -> None: | |
self.id = id | |
def __repr__(self) -> str: | |
return "Price(id=%r)" % (self.id) | |
class PriceSchema(marshmallow.Schema): | |
id = marshmallow.fields.String(allow_none=True, missing=None) | |
class Meta: | |
unknown = marshmallow.EXCLUDE | |
@marshmallow.post_load | |
def post_load(self, data): | |
return types.Price(**data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment