-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Bug Report
(A clear and concise description of what the bug is.)
mypy doesn't seem to be fully a NotImplementedError
in a parent class. In my parent class, I have an async def iter_x
function that raises this error, and this function is actually implemented in subsequent child classes. It seems that mypy thinks the paren'ts iter function function is a coroutine because it's an async def
without an await
(gotten from this issue comment). As such, I get the following error: Return type "AsyncIterator[bytes]" of "iter_x" incompatible with return type "Coroutine[Any, Any, AsyncIterator[bytes]]" in supertype "X"
.
To Reproduce
(Write your steps here:)
- Create an
AsyncIterator
async def
function in a parent class that raises aNotImplementedError
- Implement the
AsyncIterator
async def
function in a child class. Ours does async iteration / await calls, so it has to beasync def
- Run mypy and you should get an error similar to
Return type "AsyncIterator[bytes]" of "iter_x" incompatible with return type "Coroutine[Any, Any, AsyncIterator[bytes]]" in supertype "X"
Expected Behavior
(Write what you thought would happen.)
My expected behavior is that mypy would fully listen to NotImplementedError
, and not make assumptions about the base method being a coroutine because of it's lack of an "await"
Actual Behavior
mypy thinks the parent class' method is a coroutine because it's an async def
AsyncIterator
without a yield (following this issue comment)
(Write what happened.)
Your Environment
- Mypy version used: 0.782
- Mypy command-line flags: mypy
- Mypy configuration options from
mypy.ini
(and other config files): - Python version used: 3.9
- Operating system and version: Mac OS 11.4