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 happily accepts anext_via_instance, but in anext_via_type it fails with:
main.py:10: error: Incompatible return value type (got "_T_co", expected "T") [return-value]
main.py:10: error: Argument 1 has incompatible type "AsyncIterator[T]"; expected "AsyncIterator[_T_co]" [arg-type]
If I add a reveal_type(anext) in anext_via_type:
main.py:10: note: Revealed type is "def (self: typing.AsyncIterator[_T_co`1]) -> typing.Awaitable[_T_co`1]"
This behavior doesn't seem to be a recent change; it showed up on every version I spot-checked on the playground, and is still present on master. From the error message it looks like some kind of issue with TypeVar inference, but I'm not an expert.
(I'm trying to write something like anext_via_type in order to mimic the interpreter's behavior accessing a magic method in a specific circumstance; it won't accept an instance attribute, only a class attribute, so I don't want to accept an instance attribute either.)
The text was updated successfully, but these errors were encountered:
Consider the following code:
mypy happily accepts
anext_via_instance
, but inanext_via_type
it fails with:If I add a
reveal_type(anext)
inanext_via_type
:This behavior doesn't seem to be a recent change; it showed up on every version I spot-checked on the playground, and is still present on master. From the error message it looks like some kind of issue with TypeVar inference, but I'm not an expert.
(I'm trying to write something like
anext_via_type
in order to mimic the interpreter's behavior accessing a magic method in a specific circumstance; it won't accept an instance attribute, only a class attribute, so I don't want to accept an instance attribute either.)The text was updated successfully, but these errors were encountered: