-
Notifications
You must be signed in to change notification settings - Fork 12
fix serialization of pendulum.DateTime objects in JsonSerializationWriter #369
fix serialization of pendulum.DateTime objects in JsonSerializationWriter #369
Conversation
5438a74
to
3278fe8
Compare
@microsoft-github-policy-service agree |
@baywet, @andrueastman Can you please take a look? |
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 for the contribution!
Can you please also bump the patch version in the version file and add a changelog entry? (today's date, changed) to ensure a swift release.
Also, sorry about the delay in reviewing, I missed this one in my many, many notifications...
Additionally, the code needs to be formatted (see the build logs) |
…/pendulum-datetime-serialization
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.
Thank you for making the changes!
Signed-off-by: Vincent Biret <[email protected]>
@eran-av it seems some unit tests are not passing, can you have a look into it please? |
Quality Gate passedIssues Measures |
Fixed it, |
yeah this is a bit confusing: pylint + yapf |
Sync sources for changes in microsoft/kiota-serialization-json-python#369
Environment
Describe the bug
The
write_any_value
method inJsonSerializationWriter
fails to properly handlependulum.DateTime
objects. This is due to insufficient type checking, which causespendulum.DateTime
objects to be treated as non-primitive types instead of as datetime objects. Specifically, the issue stems from not usingisinstance()
to check for datetime types, which preventspendulum.DateTime
from being recognized as a subclass of the primitivedatetime.datetime
.To Reproduce
JsonSerializationWriter
instancependulum.DateTime
field (specifically as anadditional_data
dict
)pendulum.DateTime
object is not serialized correctlyExpected behavior
pendulum.DateTime
objects should be treated as datetime objects and serialized correctly, just likedatetime.datetime
objects. The serialization process should recognizependulum.DateTime
as a subclass ofdatetime.datetime
and handle it accordingly.Code to reproduce