Skip to content

Coroutines in asyncio.AbstractEventLoop are incorrectly defined #953

@miedzinski

Description

@miedzinski

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").

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: highThis issue is more important than most

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions