Skip to content
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

DM-47262: Add serializers for *Timedelta types #325

Merged
merged 1 commit into from
Nov 13, 2024
Merged

Conversation

rra
Copy link
Member

@rra rra commented Nov 13, 2024

Add serializers to HumanTimedelta and SecondsTimedelta that serialize those Pydantic fields to a float number of seconds instead of ISO 8601 durations. This means those data types now can be round-tripped (serialized and then deserialized to the original value), whereas before they could not be. This also avoids ISO 8601 durations in service replies that use models including those types.

Fix parsing of stringified floating-point number of seconds for SecondsTimedelta, which previously was truncating to an integer number of seconds.

@rra rra requested a review from fajpunk November 13, 2024 00:42
safir/src/safir/pydantic/_types.py Outdated Show resolved Hide resolved
safir/src/safir/pydantic/_types.py Outdated Show resolved Hide resolved
safir/tests/pydantic_test.py Show resolved Hide resolved
@rra rra force-pushed the tickets/DM-47262 branch from 736c932 to 65d56b2 Compare November 13, 2024 15:59
Add serializers to `HumanTimedelta` and `SecondsTimedelta` that
serialize those Pydantic fields to a float number of seconds instead
of ISO 8601 durations. This means those data types now can be
round-tripped (serialized and then deserialized to the original
value), whereas before they could not be. This also avoids ISO 8601
durations in service replies that use models including those types.

Fix parsing of stringified floating-point number of seconds for
`SecondsTimedelta`, which previously was truncating to an integer
number of seconds.
@rra rra force-pushed the tickets/DM-47262 branch from 65d56b2 to d2d5b7c Compare November 13, 2024 16:00
@rra rra merged commit 4f13093 into main Nov 13, 2024
6 checks passed
@rra rra deleted the tickets/DM-47262 branch November 13, 2024 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants