Repository navigation
Conversation
Signed-off-by: Sebastian Turner <sebastiant3484@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The generated
parse_rfc3339validator passes the string straight todatetime.strptime(..., "%Y-%m-%dT%H:%M:%S.%fZ").%fonly matches up to 6 digits, while thetimecrate's RFC 3339 serializer emits up to 9, so a value like2024-05-01T12:34:56.123456789Zcoming from a Rust service fails Pydantic validation.This change truncates the fractional part to 6 digits before calling
strptime.datetimeonly has microsecond precision, so nothing representable is lost. Strings without a fraction, or with 6 digits or fewer, are unchanged.Changes:
core/src/language/python.rs: trim the fraction in the emittedparse_rfc3339.test_serde_iso8601andtest_custom_serialize_deserialize_functionsPython snapshots.Testing:
cargo test -p typeshare-core --test snapshot_testspasses (the two Python snapshots fail without the generator change).test_serde_iso8601/output.pywith pydantic 2 and validated{"time": "2024-05-01T12:34:56.123456789Z"}: before,ValidationError; after,2024-05-01 12:34:56.123456. The 3 digit and no fraction cases behave as before.Fixes #297