Skip to content

false "not async iterable" on use of overload with async iterable #10301

@belm0

Description

@belm0

Bug Report

Using typing.overload on an async iterator doesn't behave as I expected:

@overload
async def transitions(self, value: T) -> AsyncIterator[Tuple[T, T]]: ...
@overload
async def transitions(self, predicate: P) -> AsyncIterator[Tuple[T, T]]: ...
async def transitions(self, value_or_predicate):
    # impl with yield ...

if I remove async qualifier on the overloads, it appears to work. But that doesn't seem right...

Expected Behavior

no errors on correct usage

Actual Behavior

error on usage:

error: "Coroutine[Any, Any, AsyncIterator[Tuple[str, str]]]" has no attribute "__aiter__" (not async iterable)  [attr-defined]

Your Environment

  • Mypy version used: .812
  • Python version used: 3.7.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions