-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Wrong interface for AsyncIterable #1396
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
Comments
Could you show a small code fragment (or two) showing how the current stub
is wrong, demonstrating that it works at runtime? A PR would also be
welcome but the demonstration is key.
…On Jun 7, 2017 11:57 AM, "Ask Solem" ***@***.***> wrote:
In mypy AsyncIterable has an __anext__ method, but it should not, it
should have __aiter__: An iterable is something that you can start
iterating over, and it returns an Iterator.
The code here:
https://github.com/python/typeshed/blob/0709985d0c676127eae16e18e57104
16a9ec6da8/stdlib/3/typing.pyi#L156-L164
Should be:
class AsyncIterable(Generic[_T_co]):
@AbstractMethod
def __aiter__(self) -> 'AsyncIterator[_T_co]': ...
class AsyncIterator(AsyncIterable[_T_co],
Generic[_T_co]):
@AbstractMethod
def __anext__(self) -> Awaitable[_T_co]: ...
def __aiter__(self) -> 'AsyncIterator[_T_co]': ...
That is, AsyncIterable does not have __anext__, it has only __aiter__.
I will try to figure out how to contribute a patch and tests :-)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1396>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACwrMruw1jte8ENog1h4zHRBDE6LduPTks5sBvKtgaJpZM4NzI44>
.
|
I have the fix already and I could easily submit a PR, but I'm not sure where the tests go? Would I add these tests to mypy perhaps? The test instructions mention running the mypy tests. I will try to think of a code fragment also, but is not There AsyncIterable has |
There is no convenient place to put the tests, I just want you to show the test code you ran manually to demonstrate that there is code that works at runtime but that is wrongly rejected by Python, to support this issue. You can put it in the introduction for the PR you submit. (Also link to this issue of course.) |
Uh oh!
There was an error while loading. Please reload this page.
In mypy AsyncIterable has an
__anext__
method, but it should not: it should have__aiter__
only, but that is missing.The code here:
typeshed/stdlib/3/typing.pyi
Lines 156 to 164 in 0709985
Should be:
I will try to figure out how to contribute a patch and tests :-)
The text was updated successfully, but these errors were encountered: