-
-
Notifications
You must be signed in to change notification settings - Fork 227
fix: Fix deserialization of non-required properties #334
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #334 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 47 47
Lines 1390 1390
=========================================
Hits 1390 1390 Continue to review full report at Codecov.
|
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.
Awesome, this is a great refactor! Just one residual print
to delete probably left from debugging.
This will likely conflict with #332 from what I've read, do you have a preference which gets merged first?
|
||
|
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.
Odd, I'd think that black would have removed that.
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.
Yeah, I couldn't figure out why that got added by my PR...
) | ||
|
||
template = env.get_template("date_property_template.py") | ||
content = template.render(property=prop) | ||
print(content) |
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.
print(content) |
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.
:eek: thanks
@dbanty Yeah, I think we can merge this one first and I'll address the conflicts on #332, since it has more changes to be addressed |
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.
Awesome, thanks!
Previously, a non-required datetime would generate code like this in the
from_dict
:The
if
statement is incorrect as it does not check forUnset
, and furthermore thecast
(which is best to avoid using when possible) masks the issue.This had already been fixed for models in #315, but not for dates, datetimes, enums, or files.
In this PR, I pulled out the shared logic into a higher-order macros
construct_template
, in order to fix the issue across the board.