-
-
Notifications
You must be signed in to change notification settings - Fork 178
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
Datetime support for multiple format #815
Datetime support for multiple format #815
Conversation
I am sorry but do you need something more before merging? I don't really know why this pull request stay open if there is no problem with it. |
Simply lack of benevolent maintainer time. Please keep this open. I just can't promise when it will be reviewed. To anyone, feel free to chime in and help with the review. PRs that are obviously wrong are closed, PRs that are trivially good are merged. Other PRs take time to review. Sorry about that. Thanks for contributing. |
The one thing I'm thinking about with this code is whether it should be more closely integrated with It might be better to remove |
@lafrech Thank you for your fast feeback, I just needed to know if there was something expected of me. @Bangertm You are right, finding the result of the first condition might be a little confusing. I see two options to fix that: 1 - just add a comment explaning the expected result: if field.format == "iso" or field.format is None:
# Will return { "type": "string", "format": "date-time" } as specified inside DEFAULT_FIELD_MAPPING
pass 2 - Force the result here (as you proposed if I understood you correctly?): if field.format == "iso" or field.format is None:
ret = {
"type": "string",
"format": "date-time",
} The funny thing is that if you do that you suddenly break the tests for date format. It looks like To avoid any confusion in the future, it would probably be wise to Regarding the original problem I think the option 1 is best as it doesn't break the usual flow and is still quite clear. |
44c5e73
to
c56a7ee
Compare
So I made 3 changes to the original merge request:
|
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.
Thanks! Sorry about the delay. Just a few minor questions/comments.
c56a7ee
to
2b5018a
Compare
Thank you for your review. I will be more reactive this time if you need any other change! |
48e0561
to
3a9eb5a
Compare
Made some minor fixups so this is mergeable. Thanks so much for the contribution @TheBigRoomXXL! |
Adding a function
datetime2properties
to support the differents formats ofmarshamllow.field.DateTime
.An exemple for custom DateTime format has been added to the doc in
Using Plugins / Marshmallow Plugin
The support for
timestamp
andtimestamp_ms
mean that DateTime type can be either "string" or "integer". Format can also have multiple values. Because of that 2 test where modified to account for that variability:test_field2property_type
test_field2property_formats
Then 6 tests were added to test the different output of
datetime2properties
.