core: Improve Runnable __or__ method typing annotations (#31273)

* It is possible to chain a `Runnable` with an `AsyncIterator` as seen
in `test_runnable.py`.
* Iterator and AsyncIterator Input/Output of Callables must be put
before `Callable[[Other], Any]` otherwise the pattern matching picks the
latter.
This commit is contained in:
Christophe Bornet
2025-05-19 15:32:31 +02:00
committed by GitHub
parent e1af509966
commit 17c5a1621f
3 changed files with 14 additions and 8 deletions

View File

@@ -5253,7 +5253,7 @@ async def test_runnable_gen_transform() -> None:
yield i + 1
chain: Runnable = RunnableGenerator(gen_indexes, agen_indexes) | plus_one
achain = RunnableGenerator(gen_indexes, agen_indexes) | aplus_one
achain: Runnable = RunnableGenerator(gen_indexes, agen_indexes) | aplus_one
assert chain.get_input_jsonschema() == {
"title": "gen_indexes_input",