-
-
Couldn't load subscription status.
- Fork 3k
Closed as not planned
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
The return type of async generator in the derived class cannot match the superclass definition.
To Reproduce
from abc import ABC, abstractmethod from typing import AsyncIterator, Protocol class BaseClass(ABC): @abstractmethod async def async_generator(self) -> AsyncIterator[int]: raise NotImplementedError class SubClass(BaseClass): async def async_generator(self) -> AsyncIterator[int]: yield 1 # -> Error message: Return type "AsyncIterator[int]" of "async_generator" incompatible with return type "Coroutine[Any, Any, AsyncIterator[int]]" in supertype "BaseClass" class PBaseClass(Protocol): async def async_generator(self) -> AsyncIterator[int]: pass class PSubClass(PBaseClass): async def async_generator(self) -> AsyncIterator[int]: yield 1 # -> Error message: Return type "AsyncIterator[int]" of "async_generator" incompatible with return type "Coroutine[Any, Any, AsyncIterator[int]]" in supertype "PBaseClass" **Your Environment** - Mypy version used: 1.5.1 - Mypy command-line flags: `mypy --ignore-missing-imports --config-file tox.ini $src` - Mypy configuration options from `mypy.ini` (and other config files):[mypy]
mypy_path = {[tox]module}
ignore_missing_imports = True
exclude = interview
- Python version used: 3.11.1 Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong