Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
stubs: false negativeType checkers do not report an error, but shouldType checkers do not report an error, but should
Description
The following program passes mypy type checking, but fails at runtime:
importasynciofromtypingimportAwaitableasyncdefmain() ->None: asyncdefcoro() ->Awaitable[None]: passtask=asyncio.create_task(coro()) asyncio.create_task(task) asyncio.run(main())(venv) ➜ python --version Python 3.9.6 (venv) ➜ mypy --version mypy 0.930 (venv) ➜ mypy --strict example.py Success: no issues found in 1 source file (venv) ➜ python example.py Traceback (most recent call last): File ".../create-task-types/example.py", line 10, in <module> asyncio.run(main()) File ".../python3.9/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File ".../python3.9/asyncio/base_events.py", line 642, in run_until_complete return future.result() File ".../create-task-types/example.py", line 7, in main asyncio.create_task(task) File ".../python3.9/asyncio/tasks.py", line 361, in create_task task = loop.create_task(coro) File ".../python3.9/asyncio/base_events.py", line 433, in create_task task = tasks.Task(coro, loop=self, name=name) TypeError: a coroutine was expected, got <Task pending name='Task-2' coro=<main.<locals>.coro() running at .../create-task-types/example.py:4>> Metadata
Metadata
Assignees
Labels
stubs: false negativeType checkers do not report an error, but shouldType checkers do not report an error, but should