-
Notifications
You must be signed in to change notification settings - Fork 2k
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
fix: Adjust serialization to handle PEP-585 generic types #7690
Conversation
Update: this fails for python 3.8 only, other versions work. Please hold the review @julian-risch |
@julian-risch this should be ready now, please test in both 3.8 and 3.9 Python version and verify everything. |
Pull Request Test Coverage Report for Build 9069137605Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
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.
LGTM! 👍 I also tried out the code example from the issue with python 3.8 and 3.10.
Only thing I wondered about is why we raise a ValueError
instead of a SerializationError
, which we define in haystack.core.errors. It doesn't affect this PR though and I would prefer keeping this PR as simple as small as possible.
|
* Adjust serialization to handle PEP-585 generic types * Add reno note * Simplify * PEP 585 serialization handling in sys.version_info < (3, 9)
Why:
Improves type serialization, particularly focusing on better support for PEP 585 types (e.g.,
list[Document]
, including nested versions). This enhancement is crucial for enabling more accurate serialization of generics and nested types, which directly impacts the ability to match types likelist[X]
andList[X]
in component connections after serialization.What:
haystack/utils/type_serialization.py
modification: Introduced better handling of PEP 585 typestest/utils/test_type_serialization.py
to verify the serialization and deserialization of PEP 585 types, including more complex nested types likelist[list[int]]
.How can it be used:
list[int]
or more complex nested structures likelist[list[str]]
directly.How did you test it:
list[int]
, including deeply nested types (e.g.,list[list[list[int]]]
).Notes for the reviewer: