Definition Order Matters For `types.coroutine` Decorator
Open
Nobody has claimed this yet.
bug
false-positive
topic-async
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
This fails mypy --strict (v0.782):
from types import coroutine
from typing import Any, Iterator
async def my_async_func() -> None:
await my_coro_func()
@coroutine
def my_coro_func() -> Iterator[None]:
yield None
but this passes:
from types import coroutine
from typing import Any, Iterator
@coroutine
def my_coro_func() -> Iterator[None]:
yield None
async def my_async_func() -> None:
await my_coro_func()
MyPy playground links:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the two minimal examples with mypy --strict on Python 3.8, using the linked passing and failing mypy playgrounds as references. Investigate why moving the types.coroutine-decorated function changes the result; done means both definition orders receive the same correct type-checking result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100