You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mypy produces errors, but it shouldn't because function decorated with @abstractmethod commonly has only pass, ..., raise NotImplementedError statements or docstrings in it.
Actual behavior
mypy gives errors:
scratch_1.py:15: error: "Coroutine[Any, Any, AsyncIterable[int]]" has no attribute "__aiter__" (not async iterable)
scratch_1.py:27: error: Return type "AsyncIterable[int]" of "get_nums" incompatible with return type "Coroutine[Any, Any, AsyncIterable[int]]" in supertype "NumGetter"
and that will produce no errors, but in real application I do not have an int return type there, but rather a complex class which requires some mandatory fields to be instantiated in __init__, and it would look quite weird.
But that still does not feel as it is the way it should work.
The text was updated successfully, but these errors were encountered:
Tayum
changed the title
Automatic conversion from ReturnType to Coroutine[Any, Any, ReturnType] for functions decorated with @abc.abstractmethod
Automatic conversion from ReturnType to Coroutine[Any, Any, ReturnType] for functions with "pass"
Mar 25, 2020
I guess there is a bug when checking
async def
functions with "empty" body, which are typed to returnAsyncIterable
.Please see the snippet:
mypy
produces errors, but it shouldn't because function decorated with@abstractmethod
commonly has onlypass
,...
,raise NotImplementedError
statements or docstrings in it.Actual behavior
mypy
gives errors:Expected behavior
No errors.
Versions
Mypy configuration
The easiest way I got myself escaped was to change:
to
But that gives
mypy
error:Surely I can write:
and that will produce no errors, but in real application I do not have an
int
return type there, but rather a complex class which requires some mandatory fields to be instantiated in__init__
, and it would look quite weird.That's why to overcome this I wrote:
But that still does not feel as it is the way it should work.
The text was updated successfully, but these errors were encountered: