-
Notifications
You must be signed in to change notification settings - Fork 19
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
Attr support #26
Attr support #26
Conversation
minor: adding sanic-transmute link.
I think i need to think up a edge case which can break cattrs.unstructure. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! If you could address a couple comments, that would be great.
We will probably have to wait until cattrs releases a compatible version, before merging this PR.
ubuild.py
Outdated
# api has also been changed in master branch, | ||
# let's install master branch | ||
ROOT = os.path.dirname(sys.executable) | ||
CATTR_MASTER_BRANCH = "https://github.com/Tinche/cattrs/tarball/master" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can install from git directly:
https://github.com/toumorokoshi/notebooks/blob/master/ubuild.py#L5
""" | ||
try: | ||
res = structure(value, model) | ||
except Exception as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the specific exception should be caught here. a generic try/catch could catch other issues unrelated to the destructuring of the object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make senses.
basic types and attrs classes. | ||
""" | ||
|
||
def __init__(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need to add this method if it's a no-op.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will remove
return res | ||
|
||
|
||
# Help Functions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure.
from .interface import ObjectSerializer | ||
from cattr import structure, unstructure | ||
from ..exceptions import SerializationException | ||
from cattr.vendor.typing import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are any of these imports used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha, it has been used for to_json_schema method before, but i have removed that part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will clean those up
Looks good, thanks! I don't want to merge it in while it relies on a cattrs library that's unavailable yet, so I'm putting in the attrs_support branch for now. |
I've merged this code in manually. Thanks! |
i removed the json_schema part as we are going to use your new lib.