fix(core): compare Ellipsis callable parameters by return type - #12905
Merged
sjrl merged 2 commits intoSep 24, 2026
Merged
Conversation
`_check_callable_compatibility` applied `len()` to the first element of `get_args(Callable[...])`, which is `Ellipsis` rather than a parameter list, so comparing any `Callable[..., T]` raised TypeError instead of answering. An Ellipsis parameter list now matches parameters of any signature, while return types are still compared.
Contributor
|
@Lesereingrape is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
sjrl
reviewed
Sep 24, 2026
sjrl
reviewed
Sep 24, 2026
Also shorten the release note.
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.
Related Issues
Proposed Changes:
_check_callable_compatibilitycompared the two elements ofget_args(Callable[...])— theparameter list and the return type — but for
Callable[..., T]the first element is not a parameterlist, it is the
Ellipsissentinel. Twolen()calls then hit that sentinel directly (and a thirdbuilds a stand-in parameter list from it for a bare
Callablesender), so every comparison involvingCallable[..., T]raisedTypeError: object of type 'ellipsis' has no len()instead of answering.Users see it as a crash out of
Pipeline.connect()when a component exposes or consumes aCallable[..., T]socket.The fix keeps the existing structure and treats
Ellipsisas what it means — "parameters of anysignature":
Callable[..., str]remains incompatible withCallable[[int], int];Ellipsis, there are no positions to compare, so theresult is decided by the return type alone, in both directions;
Callablesender no longer expands tolen(Ellipsis).Nested cases follow from the recursion in the last line:
Callable[[Callable[..., int]], str]is nowcompatible with
Callable[[Callable[[int], int]], str].Impact for users: pipelines that annotate a callback socket as
Callable[..., T]— the natural way towrite "some callable, signature not pinned here" — can be built again instead of failing at
construction time with an unrelated-looking standard-library error.
How did you test it?
Five cases added to
test/core/test_type_utils.py, next to the existingCallabletables, assertingboth directions plus two return-type controls. The commands behind
hatch run test:unit/fmt/test:typeswere run directly against a Python 3.12 venv withhaystackinstalled from this branch(see "Notes for the reviewer" for the exact scope):
main..._is_compatible[ellipsis-callable-to-typed-callable]TypeError: object of type 'ellipsis' has no len(),type_utils.py:214)..._is_compatible[typed-callable-to-ellipsis-callable]TypeError)..._is_compatible[nested-ellipsis-callable-to-nested-typed-callable]TypeError)..._incompatible_return_type[ellipsis-callable-to-callable-wrong-return-type](control)..._incompatible_return_type[typed-callable-to-ellipsis-wrong-return-type](control)The two
test/corefailures (test_show_in_notebook, and one case intest_serialization_security.py) reproduce identically with both changed files reverted toorigin/mainon this machine, so they are pre-existing environment failures rather than fallout fromthis change.
End-to-end check of the reported symptom, with the two-component pipeline from the issue:
Notes for the reviewer
The semantic choice is the one the surrounding code already makes for bare
Callable: an unspecifiedparameter list is not a constraint to violate, only a set of positions that cannot be compared. The
Ellipsisshort-circuit sits after the return-type check on purpose, so return types stay enforced.Environment note, stated plainly:
hatchis not available on this machine, so I did not runhatch run test:unit/hatch run fmt/hatch run test:types. I ran the tools behind them directlyagainst a Python 3.12 venv with this checkout installed editable:
pytest, the repository's pinnedruff (
v0.16.0, the rev in.pre-commit-config.yaml),mypyon the two changed files, andscripts/release_note_backticks.pyon the new release note.codespellwas not run, and pre-commithooks are not installed in this clone, so CI will be the first full hook pass.
Scope: only
haystack/core/type_utils.py:205-216changes (6 added lines, 1 modified), plus 5 testparams and the release note. I scanned the 72 open PRs and the recent history of this file for
overlap and found none — the last commits touching it are #12739 and #12737, both in unrelated
functions.
This contribution was made by an AI agent operating this account: the agent located the defect, wrote
the reproduction, the tests and the release note, and measured the before/after numbers quoted above.
No human has read the diff yet, so please review it with that in mind — it can be amended or closed on
request.
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.ruff check+ruff format --check,release_note_backticks.py) plusmypyandpytest, all clean; I could not runhatch,codespellor the full hook suite locally — see "How did you test it?" for the exact scope.