Add type information for asyncio.coroutines

This commit is contained in:
David Soria Parra
2016-01-29 15:53:21 -08:00
committed by David Soria Parra
parent 4292211da9
commit 4d0a9e6d49
4 changed files with 17 additions and 5 deletions

View File

@@ -1,9 +1,13 @@
"""The asyncio package, tracking PEP 3156."""
from asyncio.coroutines import (
coroutine as coroutine,
iscoroutinefunction as iscoroutinefunction,
iscoroutine as iscoroutine,
)
from asyncio.futures import (
Future as Future,
)
from asyncio.tasks import (
coroutine as coroutine,
sleep as sleep,
Task as Task,
FIRST_COMPLETED as FIRST_COMPLETED,
@@ -27,7 +31,8 @@ from asyncio.queues import (
QueueEmpty as QueueEmpty,
)
__all__ = (futures.__all__ +
__all__ = (coroutines.__all__ +
futures.__all__ +
tasks.__all__ +
events.__all__ +
queues.__all__)

View File

@@ -0,0 +1,8 @@
from typing import Callable, Any
__all__ = ['coroutine',
'iscoroutinefunction', 'iscoroutine']
def coroutine(func: Callable[..., Any]) -> Callable[..., Any]: ...
def iscoroutinefunction(func: Callable[..., Any]) -> bool: ...
def iscoroutine(obj: Any) -> bool: ...

View File

@@ -4,7 +4,7 @@ __all__ = ['Queue', 'PriorityQueue', 'LifoQueue', 'JoinableQueue',
'QueueFull', 'QueueEmpty']
from asyncio.events import AbstractEventLoop
from .tasks import coroutine
from .coroutines import coroutine
from .futures import Future

View File

@@ -6,7 +6,7 @@ from asyncio.futures import Future
# 'gather', 'shield',
# ]
__all__ = ['coroutine', 'Task', 'sleep',
__all__ = ['Task', 'sleep',
'FIRST_COMPLETED', 'FIRST_EXCEPTION', 'ALL_COMPLETED',
'wait', 'wait_for']
@@ -14,7 +14,6 @@ FIRST_EXCEPTION = 'FIRST_EXCEPTION'
FIRST_COMPLETED = 'FIRST_COMPLETED'
ALL_COMPLETED = 'ALL_COMPLETED'
_T = TypeVar('_T')
def coroutine(f: _T) -> _T: ... # Here comes and go a function
def sleep(delay: float, result: _T = ..., loop: AbstractEventLoop = ...) -> Future[_T]: ...
def wait(fs: List[Task[_T]], *, loop: AbstractEventLoop = ...,
timeout: float = ..., return_when: str = ...) -> Future[Tuple[Set[Future[_T]], Set[Future[_T]]]]: ...