Skip to content
13 changes: 13 additions & 0 deletions stdlib/3/asyncio/constants.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

import enum

LOG_THRESHOLD_FOR_CONNLOST_WRITES: int
ACCEPT_RETRY_DELAY: int
DEBUG_STACK_DEPTH: int
SSL_HANDSHAKE_TIMEOUT: float
SENDFILE_FALLBACK_READBUFFER_SIZE: int

class _SendfileMode(enum.Enum):
UNSUPPORTED: int = ...
TRY_NATIVE: int = ...
FALLBACK: int = ...
61 changes: 61 additions & 0 deletions stdlib/3/asyncio/proactor_events.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

from typing import Any, Mapping, Optional, Generator
from . import base_events, transports, events, streams, futures, constants
from asyncio import coroutine
from socket import socket
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal

class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTransport):

def __init__(self, loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., server: Optional[events.AbstractServer] = ...) -> None: ...
def __repr__(self) -> str: ...
def __del__(self) -> None: ...
def get_write_buffer_size(self) -> int: ...

class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTransport):

def __init__(self, loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., server: Optional[events.AbstractServer] = ...) -> None: ...

class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.WriteTransport):

def __init__(self, loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., server: Optional[events.AbstractServer] = ...) -> None: ...

class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport):

def __init__(self, loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., server: Optional[events.AbstractServer] = ...) -> None: ...

class _ProactorDuplexPipeTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport): ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't _ProactorSocketTransport included?

class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport):

_sendfile_compatible: constants._SendfileMode = ...

def __init__(self, loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., server: Optional[events.AbstractServer] = ...) -> None: ...
def _set_extra(self, sock: socket) -> None: ...
def can_write_eof(self) -> Literal[True]: ...
def write_eof(self) -> None: ...

class BaseProactorEventLoop(base_events.BaseEventLoop):

def __init__(self, proactor: Any) -> None: ...
# The methods below don't actually exist directly, ProactorEventLoops do not implement them. However, they are
# needed to satisfy mypy
if sys.version_info >= (3, 7):
async def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *, ssl: events._SSLContext = ...,
sock: Optional[socket] = ..., server_hostname: str = ...,
ssl_handshake_timeout: Optional[float] = ...) -> events._TransProtPair: ...
async def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *, sock: Optional[socket] = ...,
backlog: int = ..., ssl: events._SSLContext = ..., ssl_handshake_timeout: Optional[float] = ...,
start_serving: bool = ...) -> events.AbstractServer: ...
else:
@coroutine
def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *,
ssl: events._SSLContext = ..., sock: Optional[socket] = ...,
server_hostname: str = ...) -> Generator[Any, None, events._TransProtPair]: ...
@coroutine
def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *,
sock: Optional[socket] = ..., backlog: int = ..., ssl: events._SSLContext = ...) -> Generator[Any, None, events.AbstractServer]: ...
26 changes: 26 additions & 0 deletions stdlib/3/asyncio/selector_events.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

from typing import Optional, Any, Generator
from . import base_events, events
from socket import socket
from asyncio import coroutine
import selectors
import sys

class BaseSelectorEventLoop(base_events.BaseEventLoop):

def __init__(self, selector: selectors.BaseSelector = ...) -> None: ...
if sys.version_info >= (3, 7):
async def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *, ssl: events._SSLContext = ...,
sock: Optional[socket] = ..., server_hostname: str = ...,
ssl_handshake_timeout: Optional[float] = ...) -> events._TransProtPair: ...
async def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *, sock: Optional[socket] = ...,
backlog: int = ..., ssl: events._SSLContext = ..., ssl_handshake_timeout: Optional[float] = ...,
start_serving: bool = ...) -> events.AbstractServer: ...
else:
@coroutine
def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *,
ssl: events._SSLContext = ..., sock: Optional[socket] = ...,
server_hostname: str = ...) -> Generator[Any, None, events._TransProtPair]: ...
@coroutine
def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *,
sock: Optional[socket] = ..., backlog: int = ..., ssl: events._SSLContext = ...) -> Generator[Any, None, events.AbstractServer]: ...
5 changes: 5 additions & 0 deletions stdlib/3/asyncio/transports.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
from typing import Dict, Any, TypeVar, Mapping, List, Optional, Tuple
from asyncio.protocols import BaseProtocol
from asyncio.events import AbstractEventLoop

__all__: List[str]

Expand Down Expand Up @@ -43,3 +44,7 @@ class SubprocessTransport(BaseTransport):
def send_signal(self, signal: int) -> int: ...
def terminate(self) -> None: ...
def kill(self) -> None: ...

class _FlowControlMixin(Transport):
def __init__(self, extra: Optional[Mapping[Any, Any]] = ..., loop: Optional[AbstractEventLoop] = ...) -> None: ...
def get_write_buffer_limits(self) -> Tuple[int, int]: ...
58 changes: 58 additions & 0 deletions stdlib/3/asyncio/windows_events.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

from typing import Callable, Tuple, List, IO, Any, Optional
import socket
from . import proactor_events, events, futures, windows_utils, selector_events, streams

NULL: int
INFINITE: int
ERROR_CONNECTION_REFUSED: int
ERROR_CONNECTION_ABORTED: int
CONNECT_PIPE_INIT_DELAY: float
CONNECT_PIPE_MAX_DELAY: float

class PipeServer:

def __init__(self, address: str) -> None: ...
def __del__(self) -> None: ...
def closed(self) -> bool: ...
def close(self) -> None: ...

class _WindowsSelectorEventLoop(selector_events.BaseSelectorEventLoop): ...

class ProactorEventLoop(proactor_events.BaseProactorEventLoop):

def __init__(self, proactor: Optional[IocpProactor] = ...) -> None: ...
async def create_pipe_connection(self, protocol_factory: Callable[[], streams.StreamReaderProtocol], address: str) -> Tuple[proactor_events._ProactorDuplexPipeTransport, streams.StreamReaderProtocol]: ...
async def start_serving_pipe(self, protocol_factory: Callable[[], streams.StreamReaderProtocol], address: str) -> List[PipeServer]: ...

class IocpProactor:

def __init__(self, concurrency: int = ...) -> None: ...
def __repr__(self) -> str: ...
def __del__(self) -> None: ...
def set_loop(self, loop: events.AbstractEventLoop) -> None: ...
def select(self, timeout: Optional[int] = ...) -> List[futures.Future[Any]]: ...
def recv(self, conn: socket.socket, nbytes: int, flags: int = ...) -> futures.Future[bytes]: ...
def recv_into(self, conn: socket.socket, buf: socket._WriteBuffer, flags: int = ...) -> futures.Future[Any]: ...
def send(self, conn: socket.socket, buf: socket._WriteBuffer, flags: int = ...) -> futures.Future[Any]: ...
def accept(self, listener: socket.socket) -> futures.Future[Any]: ...
def connect(self, conn: socket.socket, address: bytes) -> futures.Future[Any]: ...
def sendfile(self, sock: socket.socket, file: IO[bytes], offset: int, count: int) -> futures.Future[Any]: ...
def accept_pipe(self, pipe: socket.socket) -> futures.Future[Any]: ...
async def connect_pipe(self, address: bytes) -> windows_utils.PipeHandle: ...
def wait_for_handle(self, handle: windows_utils.PipeHandle, timeout: int = ...) -> bool: ...
def close(self) -> None: ...

SelectorEventLoop = _WindowsSelectorEventLoop

class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
_loop_factory: events.AbstractEventLoop = ...
def get_child_watcher(self) -> Any: ...
def set_child_watcher(self, watcher: Any) -> None: ...

class WindowsProactorEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
_loop_factory: events.AbstractEventLoop = ...
def get_child_watcher(self) -> Any: ...
def set_child_watcher(self, watcher: Any) -> None: ...

DefaultEventLoopPolicy = WindowsSelectorEventLoopPolicy
21 changes: 21 additions & 0 deletions stdlib/3/asyncio/windows_utils.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

from typing import Tuple, Callable, Optional
from types import TracebackType

BUFSIZE: int = ...
PIPE: int = ...
STDOUT: int = ...

def pipe(*, duplex: bool = ..., overlapped: Tuple[bool, bool] = ..., bufsize: int = ...) -> Tuple[int, int]: ...

class PipeHandle:

def __init__(self, handle: int) -> None: ...
def __repr__(self) -> str: ...
def __del__(self) -> None: ...
def __enter__(self) -> PipeHandle: ...
def __exit__(self, t: Optional[type], v: Optional[BaseException], tb: Optional[TracebackType]) -> None: ...
@property
def handle(self) -> int: ...
def fileno(self) -> int: ...
def close(self, *, CloseHandle: Callable[[int], None] = ...) -> None: ...