Here's an example from the documentation:
import trio
from typing import List
from trio.testing import open_stream_to_socket_listener
async def handler(stream: trio.abc.Stream) -> None:
print(await stream.receive_some(1024))
async def main() -> None:
async with trio.open_nursery() as nursery:
# the problematic line
listeners: List[trio.SocketListener] = await nursery.start(
trio.serve_tcp, handler, 0
)
client_stream = await open_stream_to_socket_listener(listeners[0])
# Then send and receive data on 'client_stream', for example:
await client_stream.send_all(b"GET / HTTP/1.0\r\n\r\n")
trio.run(main)
mypy complains with this error message:
test1.py:
12:54 error mypy Argument 1 to "start" of "Nursery" has incompatible type "Callable[[Callable[[SocketStream], Awaitable[None]], int, DefaultNamedArg(Optional[AnyStr], 'host'),
DefaultNamedArg(Optional[int], 'backlog'), DefaultNamedArg(Optional[Nursery], 'handler_nursery'), NamedArg(TaskStatus[Sequence[SocketListener]], 'task_status')], Coroutine[Any, Any,
NoReturn]]"; expected <union: 5 items>
but the code runs fine... Am I missing something?
Here's an example from the documentation:
mypy complains with this error message:
but the code runs fine... Am I missing something?