Skip to content

Definition Order Matters For types.coroutine Decorator #9256

Open
@rmorshea

Description

@rmorshea

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongfalse-positivemypy gave an error on correct codetopic-asyncasync, await, asyncio

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions