-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
Updated JSON serialization of Date and CalendarDate to support None #582
Conversation
@jbednar @philippjfr Ready for review assuming the tests go green on CI (they work fine locally). |
Codecov Report
@@ Coverage Diff @@
## master #582 +/- ##
==========================================
+ Coverage 82.23% 82.41% +0.18%
==========================================
Files 4 4
Lines 2994 3014 +20
==========================================
+ Hits 2462 2484 +22
+ Misses 532 530 -2
Continue to review full report at Codecov.
|
Tests have passed except for the pypy suite due to an unrelated issue. |
Thanks! The code looks good. Some questions:
|
Thanks for prompting me to have another look! I realize that my initial impression was correct and Otherwise it is about checking how the I'll make sure |
At a glance that does look to be true but looking closer there isn't that much shared. The |
Ah, didn't spot ".date()". Ok, keeping them separate is fine. Having a general declarative implementation of the instance checks across many Parameter types would be a separate task, but would seem to simplify things. |
@philippjfr @jbednar Any idea what the rationale might have been to hardcode class Array(ClassSelector):
"""
Parameter whose value is a numpy array.
"""
def __init__(self, default=None, **params):
from numpy import ndarray
super(Array, self).__init__(ndarray, allow_None=True, default=default, **params) |
I would assume that's because Numpy is not a required dependency and thus we can't have an array as the default value. That said, I think the right thing to do is to have the default be None but not specify |
Your suggestion about Otherwise, I have added None/'null' support for |
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.
Looks good, but please consistently choose either an early return style:
if value is None:
return 'null'
return val...
or an if/else:
if value is None:
return 'null'
else:
return val...
Right now it's a mix of the two, and thus less easy to scan.
Simple fix that addresses #578 issue for
None
valuedDate
parameters and does the same forCalendarDate
parameters.