-
Notifications
You must be signed in to change notification settings - Fork 2
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
Slim dump/load implementation #146
base: main
Are you sure you want to change the base?
Conversation
|
||
def dump(self, value: Any) -> Any: | ||
if not isinstance(value, list): | ||
raise m.ValidationError("Not a valid list.") |
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.
raise m.ValidationError("Not a valid list.") | |
raise m.ValidationError("Not a valid list") |
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.
And in all other places as well
try: | ||
return uuid.UUID(value) | ||
except ValueError: | ||
raise m.ValidationError("Not a valid uuid.") |
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.
It would've been nice to see an actual value in the exception 🤔
error_messages[dataclass_field.name] = field_validation_error.messages | ||
|
||
if error_messages is not None: | ||
raise m.ValidationError(error_messages, NO_FIELD_NAME) |
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 plan to add a parent field name at some point instead of NO_FIELD_NAME
, right?
TLDR: slim methods speed up
transaction_load_dump.py
from 0.019 seconds to 0.003 seconds.Slim version:
Baseline: