-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
Hello,
Just started looking into this tool, it's great! This might be an error/misunderstanding on my part, if so i'm sorry.
Issue
I tried to naively map an async function on a Stream, but i get this error on the line | pipe.map(consumer)
error: Argument 1 has incompatible type "Callable[[str, VarArg(Any)], Coroutine[Any, Any, str]]"; expected "Callable[[str, VarArg(str)], Awaitable[Never]]" [arg-type]
Here's a minimal reproduction code
from collections.abc import AsyncGenerator
from typing import Any
from aiostream import stream, pipe, Stream
async def producer() -> AsyncGenerator[str, None]:
yield "a"
async def consumer(value: str, *_: Any) -> str:
return value + "!"
iterator: Stream[str] = (
stream.iterate(producer())
| pipe.map(consumer)
)
Fixes
If i use amap it works
If I make consumer sync, it works (but I can't, just wanted to say the typing is accurate for sync functions)
Notes
Sure i can use amap but it seems like map is suppose to handle both to make the code simpler, which is a nice idea, but it looks like a typing issue.
Versions / config
Versions:
- Python 3.12.8
- mypy 1.15.0
- aiostream 0.6.4
[tool.mypy]
namespace_packages=true
explicit_package_bases=true
strict=true
show_error_codes=true
Metadata
Metadata
Assignees
Labels
No labels