-
Notifications
You must be signed in to change notification settings - Fork 2.5k
refactor: support PEP604 typing syntax (X|Y and X|None)
#10255
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Pull Request Test Coverage Report for Build 20373119300Warning: 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 |
X|Y and X|None typing syntaxes
X|Y and X|None typing syntaxesX|Y and X|None)
sjrl
left a comment
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.
Looks good! Let's make sure to give platform plenty of heads up about this change as well. Unsure if it effects the visual builder in any way.
Related Issues
We want to use
X | Yinstead ofUnion[X, Y]andX | Noneinstead ofOptional[X]across the codebase.Since the old syntax is still valid, we also want to ensure it continues to work correctly.
Proposed Changes:
Most relevant files
Since this PR is quite large, I'm reporting here the list of files with the most relevant changes. Most of the other changes have been automatically applied using Ruff.
pyproject.toml
haystack/utils/type_serialization.py
haystack/core/type_utils.py
haystack/core/super_component/utils.py
haystack/components/agents/state/state_utils.py
haystack/tools/parameters_schema_utils.py
test/core/pipeline/test_type_syntax_compatibility.py (new)
test/utils/test_type_serialization.py
test/core/test_type_utils.py
test/core/super_component/test_utils.py
test/components/agents/test_state_class.py
test/tools/test_parameters_schema_utils.py
test/components/routers/test_conditional_router.py
How did you test it?
Notes for the reviewer
In case this PR introduces bugs that we are not able to spot immediately, I hope that testing the future Release Candidate on Platform can help surface them.
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.