Skip to content

Coroutines in asyncio.AbstractEventLoop are incorrectly defined #953

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

Closed
miedzinski opened this issue Feb 24, 2017 · 0 comments · Fixed by #958
Closed

Coroutines in asyncio.AbstractEventLoop are incorrectly defined #953

miedzinski opened this issue Feb 24, 2017 · 0 comments · Fixed by #958
Labels
priority: high This issue is more important than most

Comments

@miedzinski
Copy link
Contributor

For example AbstractEventLoop.create_connection currently has such signature

@abstractmethod
def create_connection(self, protocol_factory: Any, host: str = ..., port: int = ..., *,
                      ssl: Any = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: Any = ...,
                      local_addr: str = ..., server_hostname: str = ...) -> tuple: ...

while in docs this is definitely a coroutine. Actually, the same applies to all coroutines in AbstractEventLoop.

It is impossible to use any loop's coro methods without putting # type: ignore on every call.

async def f(l: asyncio.AbstractEventLoop) -> None:
    await l.create_connection(...)
    return None

mypy reports error: Incompatible types in await (actual type Tuple[Any, ...], expected type "Awaitable").

@ambv ambv added help wanted priority: high This issue is more important than most labels Feb 26, 2017
JelleZijlstra added a commit to JelleZijlstra/typeshed that referenced this issue Feb 27, 2017
Closes python#953.

I reviewed the documentation at https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.AbstractEventLoop
and added missing methods and missing @coroutine decorators.

I ran mypy on the sample file from the issue report to confirm that mypy handles the combination
of @AbstractMethod and @coroutine correctly.

There are a number of types in this file that are annotated as Any but could be given more precise
types (e.g., sockets and protocol factories). I may submit another PR to fix those separately.
gvanrossum pushed a commit that referenced this issue Mar 13, 2017
)

Closes #953.

I reviewed the documentation at https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.AbstractEventLoop and added missing methods and missing @coroutine decorators.

I ran mypy on the sample file from the issue report to confirm that mypy handles the combination of @AbstractMethod and @coroutine correctly.

Also fixed a number of types in this file that are annotated as Any but could be given more precise types (e.g., sockets and protocol factories).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high This issue is more important than most
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants