The following code fails to typecheck with mypy but works just fine at runtime.
importasynciofromtypingimportAsyncGeneratorasyncdeffunc() ->AsyncGenerator[int, None]:
yield1asyncdefmain() ->None:
a=func()
print(awaitasyncio.create_task(a.asend(None)))
asyncio.run(main())
Error:
❯ mypy main.pymain.py:11: error: Argument 1 to "create_task" has incompatible type "Awaitable[int]"; expected "Union[Generator[Any, None, <nothing>], Coroutine[Any, Any, <nothing>]]" [arg-type]main.py:11: error: Argument 1 to "create_task" has incompatible type "Awaitable[int]"; expected "Union[Generator[Any, None, object], Coroutine[Any, Any, object]]" [arg-type]Found 2 errors in 1 file (checked 1 source file)
mypy version: mypy 1.0.0 (compiled: yes)
The following code fails to typecheck with mypy but works just fine at runtime.
Error:
mypy version: mypy 1.0.0 (compiled: yes)