fix: add typing.Annotated support to serialize_type/deserialize_type - #12351
Closed
yashrajrr wants to merge 1 commit into
Closed
fix: add typing.Annotated support to serialize_type/deserialize_type#12351yashrajrr wants to merge 1 commit into
yashrajrr wants to merge 1 commit into
Conversation
Fixes deepset-ai#12338 - Annotated types could not be round-tripped through serialize_type/deserialize_type. Metadata values were rendered without quotes causing deserialization failures or silent corruption. Changes: - Added _parse_annotated_args() for quote-aware metadata parsing - serialize_type now uses repr() on metadata (strings keep quotes) - deserialize_type uses ast.literal_eval for safe metadata parsing - Added comprehensive test coverage
|
@yashrajrr is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Hi @yashrajrr, thanks for your interest in contributing to Haystack! 🙏 This is an automated message to help us keep the review queue healthy. |
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.
Fixes #12338 — Fix
AnnotatedType SerializationProblem
typing.Annotatedtypes were not correctly preserved byserialize_type()/deserialize_type()."int"could be incorrectly converted to theinttype.Annotatedtype hints.Changes
_parse_annotated_args()to correctly parse nested types, quoted strings, commas, and mixed quotes.repr()when serializingAnnotatedmetadata.ast.literal_eval()for safe metadata deserialization.Optional, andUnion.Tests
test_type_serialization.py: 198 tests passedTarget
deepset-ai/haystack:main←yashrajrr/haystack:fix/annotated-type-serialization