-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mypy seems to lose the type of an async AsyncIterator function that overrides a superclass #12662
Comments
Async generator signatures are a bit confusing. If there's no |
Specifically, you likely want to do one of the following:
or
|
OK, the subclass is a typing only stub that has no implementation, so users are in fact using the superclass in any case. I guess we would use the "False" trick then, or just a typing: ignore as I've been doing, or maybe just adjust the supertype to not be "async". this feels a little wrong though. an overridden method (edit: that explicitly indicates non-implemented for its body) should be able to have the identical interface as the superclass, this at the moment feels like one of the most non-intuitive things I've seen in a long time. |
The "problem" is the interaction between two facts:
Note that the first alone is enough to cause problems in synchronous code, e.g. see Line 867 in 40bbfb5
Consider:
The correspond to the following types:
In the current world, we annotate these like so:
There is an alternative, fully explicit world in which we annotate them like this. This would avoid the confusion here, but make async types quite cumbersome to use:
|
I understand all of that. the issue is that a method that has if the bigger issue here is that when libraries move from .pyi files to inline typing, there still needs to be facilities to create interfaces that are "typing only", classes, methods and functions that aren't actually used at runtime. My assumption was that usage of the ellipses |
in fact I know that mypy considers So I think this is still a bug. mypy should not be assuming anything about the contents of this method. |
Getting this both with 0.942 as well as latest master:
error:
if you remove the implementation from
AsyncResultBroken.partitions
, then it passes. So, I'm wondering am I not usingAsyncIterator
correctly? but if I'm not, neither mypy nor pyright are saying anything. Also, even if the method body ofpartitions
were wrong, the signatures match exactly.The text was updated successfully, but these errors were encountered: