Require coroutines for create_task() (#6779)

This commit is contained in:
Nikita Sobolev
2022-02-02 15:35:00 +03:00
committed by GitHub
parent 970b8a676c
commit 1b99812621
3 changed files with 11 additions and 9 deletions

View File

@@ -3,7 +3,7 @@ import sys
from _typeshed import FileDescriptorLike, Self
from abc import ABCMeta, abstractmethod
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
from typing import IO, Any, Awaitable, Callable, Generator, Sequence, TypeVar, Union, overload
from typing import IO, Any, Awaitable, Callable, Coroutine, Generator, Sequence, TypeVar, Union, overload
from typing_extensions import Literal
from .base_events import Server
@@ -103,10 +103,12 @@ class AbstractEventLoop(metaclass=ABCMeta):
# Tasks methods
if sys.version_info >= (3, 8):
@abstractmethod
def create_task(self, coro: Awaitable[_T] | Generator[Any, None, _T], *, name: str | None = ...) -> Task[_T]: ...
def create_task(
self, coro: Coroutine[Any, Any, _T] | Generator[Any, None, _T], *, name: str | None = ...
) -> Task[_T]: ...
else:
@abstractmethod
def create_task(self, coro: Awaitable[_T] | Generator[Any, None, _T]) -> Task[_T]: ...
def create_task(self, coro: Coroutine[Any, Any, _T] | Generator[Any, None, _T]) -> Task[_T]: ...
@abstractmethod
def set_task_factory(self, factory: Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]] | None) -> None: ...