mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 14:01:55 +08:00
Re-organize directory structure (#4971)
See discussion in #2491 Co-authored-by: Ivan Levkivskyi <ilevkivskyi@dropbox.com>
This commit is contained in:
116
stdlib/asyncio/__init__.pyi
Normal file
116
stdlib/asyncio/__init__.pyi
Normal file
@@ -0,0 +1,116 @@
|
||||
import sys
|
||||
from typing import Type
|
||||
|
||||
from .base_events import BaseEventLoop as BaseEventLoop
|
||||
from .coroutines import coroutine as coroutine, iscoroutine as iscoroutine, iscoroutinefunction as iscoroutinefunction
|
||||
from .events import (
|
||||
AbstractEventLoop as AbstractEventLoop,
|
||||
AbstractEventLoopPolicy as AbstractEventLoopPolicy,
|
||||
AbstractServer as AbstractServer,
|
||||
Handle as Handle,
|
||||
TimerHandle as TimerHandle,
|
||||
_get_running_loop as _get_running_loop,
|
||||
_set_running_loop as _set_running_loop,
|
||||
get_child_watcher as get_child_watcher,
|
||||
get_event_loop as get_event_loop,
|
||||
get_event_loop_policy as get_event_loop_policy,
|
||||
new_event_loop as new_event_loop,
|
||||
set_child_watcher as set_child_watcher,
|
||||
set_event_loop as set_event_loop,
|
||||
set_event_loop_policy as set_event_loop_policy,
|
||||
)
|
||||
from .futures import Future as Future, isfuture as isfuture, wrap_future as wrap_future
|
||||
from .locks import (
|
||||
BoundedSemaphore as BoundedSemaphore,
|
||||
Condition as Condition,
|
||||
Event as Event,
|
||||
Lock as Lock,
|
||||
Semaphore as Semaphore,
|
||||
)
|
||||
from .protocols import (
|
||||
BaseProtocol as BaseProtocol,
|
||||
DatagramProtocol as DatagramProtocol,
|
||||
Protocol as Protocol,
|
||||
SubprocessProtocol as SubprocessProtocol,
|
||||
)
|
||||
from .queues import (
|
||||
LifoQueue as LifoQueue,
|
||||
PriorityQueue as PriorityQueue,
|
||||
Queue as Queue,
|
||||
QueueEmpty as QueueEmpty,
|
||||
QueueFull as QueueFull,
|
||||
)
|
||||
from .streams import (
|
||||
StreamReader as StreamReader,
|
||||
StreamReaderProtocol as StreamReaderProtocol,
|
||||
StreamWriter as StreamWriter,
|
||||
open_connection as open_connection,
|
||||
start_server as start_server,
|
||||
)
|
||||
from .subprocess import create_subprocess_exec as create_subprocess_exec, create_subprocess_shell as create_subprocess_shell
|
||||
from .tasks import (
|
||||
ALL_COMPLETED as ALL_COMPLETED,
|
||||
FIRST_COMPLETED as FIRST_COMPLETED,
|
||||
FIRST_EXCEPTION as FIRST_EXCEPTION,
|
||||
Task as Task,
|
||||
as_completed as as_completed,
|
||||
ensure_future as ensure_future,
|
||||
gather as gather,
|
||||
run_coroutine_threadsafe as run_coroutine_threadsafe,
|
||||
shield as shield,
|
||||
sleep as sleep,
|
||||
wait as wait,
|
||||
wait_for as wait_for,
|
||||
)
|
||||
from .transports import (
|
||||
BaseTransport as BaseTransport,
|
||||
DatagramTransport as DatagramTransport,
|
||||
ReadTransport as ReadTransport,
|
||||
SubprocessTransport as SubprocessTransport,
|
||||
Transport as Transport,
|
||||
WriteTransport as WriteTransport,
|
||||
)
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from .events import get_running_loop as get_running_loop
|
||||
if sys.version_info >= (3, 8):
|
||||
from .exceptions import (
|
||||
CancelledError as CancelledError,
|
||||
IncompleteReadError as IncompleteReadError,
|
||||
InvalidStateError as InvalidStateError,
|
||||
LimitOverrunError as LimitOverrunError,
|
||||
SendfileNotAvailableError as SendfileNotAvailableError,
|
||||
TimeoutError as TimeoutError,
|
||||
)
|
||||
else:
|
||||
if sys.version_info >= (3, 7):
|
||||
from .events import SendfileNotAvailableError as SendfileNotAvailableError
|
||||
from .futures import CancelledError as CancelledError, InvalidStateError as InvalidStateError, TimeoutError as TimeoutError
|
||||
from .streams import IncompleteReadError as IncompleteReadError, LimitOverrunError as LimitOverrunError
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from .protocols import BufferedProtocol as BufferedProtocol
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from .runners import run as run
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from .tasks import all_tasks as all_tasks, create_task as create_task, current_task as current_task
|
||||
if sys.version_info >= (3, 9):
|
||||
from .threads import to_thread as to_thread
|
||||
|
||||
DefaultEventLoopPolicy: Type[AbstractEventLoopPolicy]
|
||||
if sys.platform == "win32":
|
||||
from .windows_events import *
|
||||
|
||||
if sys.platform != "win32":
|
||||
from .streams import open_unix_connection as open_unix_connection, start_unix_server as start_unix_server
|
||||
from .unix_events import (
|
||||
AbstractChildWatcher as AbstractChildWatcher,
|
||||
FastChildWatcher as FastChildWatcher,
|
||||
SafeChildWatcher as SafeChildWatcher,
|
||||
SelectorEventLoop as SelectorEventLoop,
|
||||
)
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from .unix_events import MultiLoopChildWatcher as MultiLoopChildWatcher, ThreadedChildWatcher as ThreadedChildWatcher
|
||||
354
stdlib/asyncio/base_events.pyi
Normal file
354
stdlib/asyncio/base_events.pyi
Normal file
@@ -0,0 +1,354 @@
|
||||
import ssl
|
||||
import sys
|
||||
from _typeshed import FileDescriptorLike
|
||||
from abc import ABCMeta
|
||||
from asyncio.events import AbstractEventLoop, AbstractServer, Handle, TimerHandle
|
||||
from asyncio.futures import Future
|
||||
from asyncio.protocols import BaseProtocol
|
||||
from asyncio.tasks import Task
|
||||
from asyncio.transports import BaseTransport
|
||||
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
|
||||
from typing import IO, Any, Awaitable, Callable, Dict, Generator, List, Optional, Sequence, Tuple, TypeVar, Union, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from contextvars import Context
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_Context = Dict[str, Any]
|
||||
_ExceptionHandler = Callable[[AbstractEventLoop, _Context], Any]
|
||||
_ProtocolFactory = Callable[[], BaseProtocol]
|
||||
_SSLContext = Union[bool, None, ssl.SSLContext]
|
||||
_TransProtPair = Tuple[BaseTransport, BaseProtocol]
|
||||
|
||||
class Server(AbstractServer): ...
|
||||
|
||||
class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
|
||||
def run_forever(self) -> None: ...
|
||||
# Can't use a union, see mypy issue # 1873.
|
||||
@overload
|
||||
def run_until_complete(self, future: Generator[Any, None, _T]) -> _T: ...
|
||||
@overload
|
||||
def run_until_complete(self, future: Awaitable[_T]) -> _T: ...
|
||||
def stop(self) -> None: ...
|
||||
def is_running(self) -> bool: ...
|
||||
def is_closed(self) -> bool: ...
|
||||
def close(self) -> None: ...
|
||||
async def shutdown_asyncgens(self) -> None: ...
|
||||
# Methods scheduling callbacks. All these return Handles.
|
||||
if sys.version_info >= (3, 7):
|
||||
def call_soon(self, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ...) -> Handle: ...
|
||||
def call_later(
|
||||
self, delay: float, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ...
|
||||
) -> TimerHandle: ...
|
||||
def call_at(
|
||||
self, when: float, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ...
|
||||
) -> TimerHandle: ...
|
||||
else:
|
||||
def call_soon(self, callback: Callable[..., Any], *args: Any) -> Handle: ...
|
||||
def call_later(self, delay: float, callback: Callable[..., Any], *args: Any) -> TimerHandle: ...
|
||||
def call_at(self, when: float, callback: Callable[..., Any], *args: Any) -> TimerHandle: ...
|
||||
def time(self) -> float: ...
|
||||
# Future methods
|
||||
def create_future(self) -> Future[Any]: ...
|
||||
# Tasks methods
|
||||
if sys.version_info >= (3, 8):
|
||||
def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]], *, name: Optional[str] = ...) -> Task[_T]: ...
|
||||
else:
|
||||
def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ...
|
||||
def set_task_factory(
|
||||
self, factory: Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]
|
||||
) -> None: ...
|
||||
def get_task_factory(self) -> Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]: ...
|
||||
# Methods for interacting with threads
|
||||
if sys.version_info >= (3, 7):
|
||||
def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ...) -> Handle: ...
|
||||
else:
|
||||
def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any) -> Handle: ...
|
||||
def run_in_executor(self, executor: Any, func: Callable[..., _T], *args: Any) -> Future[_T]: ...
|
||||
def set_default_executor(self, executor: Any) -> None: ...
|
||||
# Network I/O methods returning Futures.
|
||||
async def getaddrinfo(
|
||||
self,
|
||||
host: Optional[str],
|
||||
port: Union[str, int, None],
|
||||
*,
|
||||
family: int = ...,
|
||||
type: int = ...,
|
||||
proto: int = ...,
|
||||
flags: int = ...,
|
||||
) -> List[Tuple[AddressFamily, SocketKind, int, str, Union[Tuple[str, int], Tuple[str, int, int, int]]]]: ...
|
||||
async def getnameinfo(
|
||||
self, sockaddr: Union[Tuple[str, int], Tuple[str, int, int, int]], flags: int = ...
|
||||
) -> Tuple[str, str]: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
@overload
|
||||
async def create_connection(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: str = ...,
|
||||
port: int = ...,
|
||||
*,
|
||||
ssl: _SSLContext = ...,
|
||||
family: int = ...,
|
||||
proto: int = ...,
|
||||
flags: int = ...,
|
||||
sock: None = ...,
|
||||
local_addr: Optional[Tuple[str, int]] = ...,
|
||||
server_hostname: Optional[str] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
happy_eyeballs_delay: Optional[float] = ...,
|
||||
interleave: Optional[int] = ...,
|
||||
) -> _TransProtPair: ...
|
||||
@overload
|
||||
async def create_connection(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: None = ...,
|
||||
port: None = ...,
|
||||
*,
|
||||
ssl: _SSLContext = ...,
|
||||
family: int = ...,
|
||||
proto: int = ...,
|
||||
flags: int = ...,
|
||||
sock: socket,
|
||||
local_addr: None = ...,
|
||||
server_hostname: Optional[str] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
happy_eyeballs_delay: Optional[float] = ...,
|
||||
interleave: Optional[int] = ...,
|
||||
) -> _TransProtPair: ...
|
||||
elif sys.version_info >= (3, 7):
|
||||
@overload
|
||||
async def create_connection(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: str = ...,
|
||||
port: int = ...,
|
||||
*,
|
||||
ssl: _SSLContext = ...,
|
||||
family: int = ...,
|
||||
proto: int = ...,
|
||||
flags: int = ...,
|
||||
sock: None = ...,
|
||||
local_addr: Optional[Tuple[str, int]] = ...,
|
||||
server_hostname: Optional[str] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
) -> _TransProtPair: ...
|
||||
@overload
|
||||
async def create_connection(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: None = ...,
|
||||
port: None = ...,
|
||||
*,
|
||||
ssl: _SSLContext = ...,
|
||||
family: int = ...,
|
||||
proto: int = ...,
|
||||
flags: int = ...,
|
||||
sock: socket,
|
||||
local_addr: None = ...,
|
||||
server_hostname: Optional[str] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
) -> _TransProtPair: ...
|
||||
else:
|
||||
@overload
|
||||
async def create_connection(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: str = ...,
|
||||
port: int = ...,
|
||||
*,
|
||||
ssl: _SSLContext = ...,
|
||||
family: int = ...,
|
||||
proto: int = ...,
|
||||
flags: int = ...,
|
||||
sock: None = ...,
|
||||
local_addr: Optional[Tuple[str, int]] = ...,
|
||||
server_hostname: Optional[str] = ...,
|
||||
) -> _TransProtPair: ...
|
||||
@overload
|
||||
async def create_connection(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: None = ...,
|
||||
port: None = ...,
|
||||
*,
|
||||
ssl: _SSLContext = ...,
|
||||
family: int = ...,
|
||||
proto: int = ...,
|
||||
flags: int = ...,
|
||||
sock: socket,
|
||||
local_addr: None = ...,
|
||||
server_hostname: Optional[str] = ...,
|
||||
) -> _TransProtPair: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
async def sock_sendfile(
|
||||
self, sock: socket, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *, fallback: bool = ...
|
||||
) -> int: ...
|
||||
@overload
|
||||
async def create_server(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: Optional[Union[str, Sequence[str]]] = ...,
|
||||
port: int = ...,
|
||||
*,
|
||||
family: int = ...,
|
||||
flags: int = ...,
|
||||
sock: None = ...,
|
||||
backlog: int = ...,
|
||||
ssl: _SSLContext = ...,
|
||||
reuse_address: Optional[bool] = ...,
|
||||
reuse_port: Optional[bool] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
start_serving: bool = ...,
|
||||
) -> Server: ...
|
||||
@overload
|
||||
async def create_server(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: None = ...,
|
||||
port: None = ...,
|
||||
*,
|
||||
family: int = ...,
|
||||
flags: int = ...,
|
||||
sock: socket = ...,
|
||||
backlog: int = ...,
|
||||
ssl: _SSLContext = ...,
|
||||
reuse_address: Optional[bool] = ...,
|
||||
reuse_port: Optional[bool] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
start_serving: bool = ...,
|
||||
) -> Server: ...
|
||||
async def connect_accepted_socket(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
sock: socket,
|
||||
*,
|
||||
ssl: _SSLContext = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
) -> _TransProtPair: ...
|
||||
async def sendfile(
|
||||
self,
|
||||
transport: BaseTransport,
|
||||
file: IO[bytes],
|
||||
offset: int = ...,
|
||||
count: Optional[int] = ...,
|
||||
*,
|
||||
fallback: bool = ...,
|
||||
) -> int: ...
|
||||
async def start_tls(
|
||||
self,
|
||||
transport: BaseTransport,
|
||||
protocol: BaseProtocol,
|
||||
sslcontext: ssl.SSLContext,
|
||||
*,
|
||||
server_side: bool = ...,
|
||||
server_hostname: Optional[str] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
) -> BaseTransport: ...
|
||||
else:
|
||||
@overload
|
||||
async def create_server(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: Optional[Union[str, Sequence[str]]] = ...,
|
||||
port: int = ...,
|
||||
*,
|
||||
family: int = ...,
|
||||
flags: int = ...,
|
||||
sock: None = ...,
|
||||
backlog: int = ...,
|
||||
ssl: _SSLContext = ...,
|
||||
reuse_address: Optional[bool] = ...,
|
||||
reuse_port: Optional[bool] = ...,
|
||||
) -> Server: ...
|
||||
@overload
|
||||
async def create_server(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: None = ...,
|
||||
port: None = ...,
|
||||
*,
|
||||
family: int = ...,
|
||||
flags: int = ...,
|
||||
sock: socket,
|
||||
backlog: int = ...,
|
||||
ssl: _SSLContext = ...,
|
||||
reuse_address: Optional[bool] = ...,
|
||||
reuse_port: Optional[bool] = ...,
|
||||
) -> Server: ...
|
||||
async def connect_accepted_socket(
|
||||
self, protocol_factory: _ProtocolFactory, sock: socket, *, ssl: _SSLContext = ...
|
||||
) -> _TransProtPair: ...
|
||||
async def create_datagram_endpoint(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
local_addr: Optional[Tuple[str, int]] = ...,
|
||||
remote_addr: Optional[Tuple[str, int]] = ...,
|
||||
*,
|
||||
family: int = ...,
|
||||
proto: int = ...,
|
||||
flags: int = ...,
|
||||
reuse_address: Optional[bool] = ...,
|
||||
reuse_port: Optional[bool] = ...,
|
||||
allow_broadcast: Optional[bool] = ...,
|
||||
sock: Optional[socket] = ...,
|
||||
) -> _TransProtPair: ...
|
||||
# Pipes and subprocesses.
|
||||
async def connect_read_pipe(self, protocol_factory: _ProtocolFactory, pipe: Any) -> _TransProtPair: ...
|
||||
async def connect_write_pipe(self, protocol_factory: _ProtocolFactory, pipe: Any) -> _TransProtPair: ...
|
||||
async def subprocess_shell(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
cmd: Union[bytes, str],
|
||||
*,
|
||||
stdin: Any = ...,
|
||||
stdout: Any = ...,
|
||||
stderr: Any = ...,
|
||||
universal_newlines: Literal[False] = ...,
|
||||
shell: Literal[True] = ...,
|
||||
bufsize: Literal[0] = ...,
|
||||
encoding: None = ...,
|
||||
errors: None = ...,
|
||||
text: Literal[False, None] = ...,
|
||||
**kwargs: Any,
|
||||
) -> _TransProtPair: ...
|
||||
async def subprocess_exec(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
*args: Any,
|
||||
stdin: Any = ...,
|
||||
stdout: Any = ...,
|
||||
stderr: Any = ...,
|
||||
**kwargs: Any,
|
||||
) -> _TransProtPair: ...
|
||||
def add_reader(self, fd: FileDescriptorLike, callback: Callable[..., Any], *args: Any) -> None: ...
|
||||
def remove_reader(self, fd: FileDescriptorLike) -> None: ...
|
||||
def add_writer(self, fd: FileDescriptorLike, callback: Callable[..., Any], *args: Any) -> None: ...
|
||||
def remove_writer(self, fd: FileDescriptorLike) -> None: ...
|
||||
# Completion based I/O methods returning Futures prior to 3.7
|
||||
if sys.version_info >= (3, 7):
|
||||
async def sock_recv(self, sock: socket, nbytes: int) -> bytes: ...
|
||||
async def sock_recv_into(self, sock: socket, buf: bytearray) -> int: ...
|
||||
async def sock_sendall(self, sock: socket, data: bytes) -> None: ...
|
||||
async def sock_connect(self, sock: socket, address: _Address) -> None: ...
|
||||
async def sock_accept(self, sock: socket) -> Tuple[socket, _RetAddress]: ...
|
||||
else:
|
||||
def sock_recv(self, sock: socket, nbytes: int) -> Future[bytes]: ...
|
||||
def sock_sendall(self, sock: socket, data: bytes) -> Future[None]: ...
|
||||
def sock_connect(self, sock: socket, address: _Address) -> Future[None]: ...
|
||||
def sock_accept(self, sock: socket) -> Future[Tuple[socket, _RetAddress]]: ...
|
||||
# Signal handling.
|
||||
def add_signal_handler(self, sig: int, callback: Callable[..., Any], *args: Any) -> None: ...
|
||||
def remove_signal_handler(self, sig: int) -> None: ...
|
||||
# Error handlers.
|
||||
def set_exception_handler(self, handler: Optional[_ExceptionHandler]) -> None: ...
|
||||
def get_exception_handler(self) -> Optional[_ExceptionHandler]: ...
|
||||
def default_exception_handler(self, context: _Context) -> None: ...
|
||||
def call_exception_handler(self, context: _Context) -> None: ...
|
||||
# Debug flag management.
|
||||
def get_debug(self) -> bool: ...
|
||||
def set_debug(self, enabled: bool) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
async def shutdown_default_executor(self) -> None: ...
|
||||
22
stdlib/asyncio/base_futures.pyi
Normal file
22
stdlib/asyncio/base_futures.pyi
Normal file
@@ -0,0 +1,22 @@
|
||||
import sys
|
||||
from typing import Any, Callable, List, Sequence, Tuple
|
||||
from typing_extensions import Literal
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from contextvars import Context
|
||||
|
||||
from . import futures
|
||||
|
||||
_PENDING: Literal["PENDING"] # undocumented
|
||||
_CANCELLED: Literal["CANCELLED"] # undocumented
|
||||
_FINISHED: Literal["FINISHED"] # undocumented
|
||||
|
||||
def isfuture(obj: object) -> bool: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
def _format_callbacks(cb: Sequence[Tuple[Callable[[futures.Future[Any]], None], Context]]) -> str: ... # undocumented
|
||||
|
||||
else:
|
||||
def _format_callbacks(cb: Sequence[Callable[[futures.Future[Any]], None]]) -> str: ... # undocumented
|
||||
|
||||
def _future_repr_info(future: futures.Future[Any]) -> List[str]: ... # undocumented
|
||||
72
stdlib/asyncio/base_subprocess.pyi
Normal file
72
stdlib/asyncio/base_subprocess.pyi
Normal file
@@ -0,0 +1,72 @@
|
||||
import subprocess
|
||||
from typing import IO, Any, Callable, Deque, Dict, List, Optional, Sequence, Tuple, Union
|
||||
|
||||
from . import events, futures, protocols, transports
|
||||
|
||||
_File = Optional[Union[int, IO[Any]]]
|
||||
|
||||
class BaseSubprocessTransport(transports.SubprocessTransport):
|
||||
|
||||
_closed: bool # undocumented
|
||||
_protocol: protocols.SubprocessProtocol # undocumented
|
||||
_loop: events.AbstractEventLoop # undocumented
|
||||
_proc: Optional[subprocess.Popen[Any]] # undocumented
|
||||
_pid: Optional[int] # undocumented
|
||||
_returncode: Optional[int] # undocumented
|
||||
_exit_waiters: List[futures.Future[Any]] # undocumented
|
||||
_pending_calls: Deque[Tuple[Callable[..., Any], Tuple[Any, ...]]] # undocumented
|
||||
_pipes: Dict[int, _File] # undocumented
|
||||
_finished: bool # undocumented
|
||||
def __init__(
|
||||
self,
|
||||
loop: events.AbstractEventLoop,
|
||||
protocol: protocols.SubprocessProtocol,
|
||||
args: Union[str, bytes, Sequence[Union[str, bytes]]],
|
||||
shell: bool,
|
||||
stdin: _File,
|
||||
stdout: _File,
|
||||
stderr: _File,
|
||||
bufsize: int,
|
||||
waiter: Optional[futures.Future[Any]] = ...,
|
||||
extra: Optional[Any] = ...,
|
||||
**kwargs: Any,
|
||||
) -> None: ...
|
||||
def _start(
|
||||
self,
|
||||
args: Union[str, bytes, Sequence[Union[str, bytes]]],
|
||||
shell: bool,
|
||||
stdin: _File,
|
||||
stdout: _File,
|
||||
stderr: _File,
|
||||
bufsize: int,
|
||||
**kwargs: Any,
|
||||
) -> None: ... # undocumented
|
||||
def set_protocol(self, protocol: protocols.BaseProtocol) -> None: ...
|
||||
def get_protocol(self) -> protocols.BaseProtocol: ...
|
||||
def is_closing(self) -> bool: ...
|
||||
def close(self) -> None: ...
|
||||
def get_pid(self) -> Optional[int]: ... # type: ignore
|
||||
def get_returncode(self) -> Optional[int]: ...
|
||||
def get_pipe_transport(self, fd: int) -> _File: ... # type: ignore
|
||||
def _check_proc(self) -> None: ... # undocumented
|
||||
def send_signal(self, signal: int) -> None: ... # type: ignore
|
||||
def terminate(self) -> None: ...
|
||||
def kill(self) -> None: ...
|
||||
async def _connect_pipes(self, waiter: Optional[futures.Future[Any]]) -> None: ... # undocumented
|
||||
def _call(self, cb: Callable[..., Any], *data: Any) -> None: ... # undocumented
|
||||
def _pipe_connection_lost(self, fd: int, exc: Optional[BaseException]) -> None: ... # undocumented
|
||||
def _pipe_data_received(self, fd: int, data: bytes) -> None: ... # undocumented
|
||||
def _process_exited(self, returncode: int) -> None: ... # undocumented
|
||||
async def _wait(self) -> int: ... # undocumented
|
||||
def _try_finish(self) -> None: ... # undocumented
|
||||
def _call_connection_lost(self, exc: Optional[BaseException]) -> None: ... # undocumented
|
||||
|
||||
class WriteSubprocessPipeProto(protocols.BaseProtocol): # undocumented
|
||||
def __init__(self, proc: BaseSubprocessTransport, fd: int) -> None: ...
|
||||
def connection_made(self, transport: transports.BaseTransport) -> None: ...
|
||||
def connection_lost(self, exc: Optional[BaseException]) -> None: ...
|
||||
def pause_writing(self) -> None: ...
|
||||
def resume_writing(self) -> None: ...
|
||||
|
||||
class ReadSubprocessPipeProto(WriteSubprocessPipeProto, protocols.Protocol): # undocumented
|
||||
def data_received(self, data: bytes) -> None: ...
|
||||
9
stdlib/asyncio/base_tasks.pyi
Normal file
9
stdlib/asyncio/base_tasks.pyi
Normal file
@@ -0,0 +1,9 @@
|
||||
from _typeshed import AnyPath
|
||||
from types import FrameType
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from . import tasks
|
||||
|
||||
def _task_repr_info(task: tasks.Task[Any]) -> List[str]: ... # undocumented
|
||||
def _task_get_stack(task: tasks.Task[Any], limit: Optional[int]) -> List[FrameType]: ... # undocumented
|
||||
def _task_print_stack(task: tasks.Task[Any], limit: Optional[int], file: AnyPath) -> None: ... # undocumented
|
||||
8
stdlib/asyncio/compat.pyi
Normal file
8
stdlib/asyncio/compat.pyi
Normal file
@@ -0,0 +1,8 @@
|
||||
import sys
|
||||
from typing import List
|
||||
|
||||
if sys.version_info < (3, 7):
|
||||
PY34: bool
|
||||
PY35: bool
|
||||
PY352: bool
|
||||
def flatten_list_bytes(list_of_data: List[bytes]) -> bytes: ...
|
||||
14
stdlib/asyncio/constants.pyi
Normal file
14
stdlib/asyncio/constants.pyi
Normal file
@@ -0,0 +1,14 @@
|
||||
import enum
|
||||
import sys
|
||||
|
||||
LOG_THRESHOLD_FOR_CONNLOST_WRITES: int
|
||||
ACCEPT_RETRY_DELAY: int
|
||||
DEBUG_STACK_DEPTH: int
|
||||
if sys.version_info >= (3, 7):
|
||||
SSL_HANDSHAKE_TIMEOUT: float
|
||||
SENDFILE_FALLBACK_READBUFFER_SIZE: int
|
||||
|
||||
class _SendfileMode(enum.Enum):
|
||||
UNSUPPORTED: int = ...
|
||||
TRY_NATIVE: int = ...
|
||||
FALLBACK: int = ...
|
||||
7
stdlib/asyncio/coroutines.pyi
Normal file
7
stdlib/asyncio/coroutines.pyi
Normal file
@@ -0,0 +1,7 @@
|
||||
from typing import Any, Callable, TypeVar
|
||||
|
||||
_F = TypeVar("_F", bound=Callable[..., Any])
|
||||
|
||||
def coroutine(func: _F) -> _F: ...
|
||||
def iscoroutinefunction(func: Callable[..., Any]) -> bool: ...
|
||||
def iscoroutine(obj: Any) -> bool: ...
|
||||
501
stdlib/asyncio/events.pyi
Normal file
501
stdlib/asyncio/events.pyi
Normal file
@@ -0,0 +1,501 @@
|
||||
import ssl
|
||||
import sys
|
||||
from _typeshed import FileDescriptorLike
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from asyncio.futures import Future
|
||||
from asyncio.protocols import BaseProtocol
|
||||
from asyncio.tasks import Task
|
||||
from asyncio.transports import BaseTransport
|
||||
from asyncio.unix_events import AbstractChildWatcher
|
||||
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
|
||||
from typing import IO, Any, Awaitable, Callable, Dict, Generator, List, Optional, Sequence, Tuple, TypeVar, Union, overload
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from contextvars import Context
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_Context = Dict[str, Any]
|
||||
_ExceptionHandler = Callable[[AbstractEventLoop, _Context], Any]
|
||||
_ProtocolFactory = Callable[[], BaseProtocol]
|
||||
_SSLContext = Union[bool, None, ssl.SSLContext]
|
||||
_TransProtPair = Tuple[BaseTransport, BaseProtocol]
|
||||
|
||||
class Handle:
|
||||
_cancelled = False
|
||||
_args: Sequence[Any]
|
||||
if sys.version_info >= (3, 7):
|
||||
def __init__(
|
||||
self, callback: Callable[..., Any], args: Sequence[Any], loop: AbstractEventLoop, context: Optional[Context] = ...
|
||||
) -> None: ...
|
||||
else:
|
||||
def __init__(self, callback: Callable[..., Any], args: Sequence[Any], loop: AbstractEventLoop) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def cancel(self) -> None: ...
|
||||
def _run(self) -> None: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def cancelled(self) -> bool: ...
|
||||
|
||||
class TimerHandle(Handle):
|
||||
if sys.version_info >= (3, 7):
|
||||
def __init__(
|
||||
self,
|
||||
when: float,
|
||||
callback: Callable[..., Any],
|
||||
args: Sequence[Any],
|
||||
loop: AbstractEventLoop,
|
||||
context: Optional[Context] = ...,
|
||||
) -> None: ...
|
||||
else:
|
||||
def __init__(self, when: float, callback: Callable[..., Any], args: Sequence[Any], loop: AbstractEventLoop) -> None: ...
|
||||
def __hash__(self) -> int: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def when(self) -> float: ...
|
||||
|
||||
class AbstractServer:
|
||||
sockets: Optional[List[socket]]
|
||||
def close(self) -> None: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
async def __aenter__(self: _T) -> _T: ...
|
||||
async def __aexit__(self, *exc: Any) -> None: ...
|
||||
def get_loop(self) -> AbstractEventLoop: ...
|
||||
def is_serving(self) -> bool: ...
|
||||
async def start_serving(self) -> None: ...
|
||||
async def serve_forever(self) -> None: ...
|
||||
async def wait_closed(self) -> None: ...
|
||||
|
||||
class AbstractEventLoop(metaclass=ABCMeta):
|
||||
slow_callback_duration: float = ...
|
||||
@abstractmethod
|
||||
def run_forever(self) -> None: ...
|
||||
# Can't use a union, see mypy issue # 1873.
|
||||
@overload
|
||||
@abstractmethod
|
||||
def run_until_complete(self, future: Generator[Any, None, _T]) -> _T: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
def run_until_complete(self, future: Awaitable[_T]) -> _T: ...
|
||||
@abstractmethod
|
||||
def stop(self) -> None: ...
|
||||
@abstractmethod
|
||||
def is_running(self) -> bool: ...
|
||||
@abstractmethod
|
||||
def is_closed(self) -> bool: ...
|
||||
@abstractmethod
|
||||
def close(self) -> None: ...
|
||||
@abstractmethod
|
||||
async def shutdown_asyncgens(self) -> None: ...
|
||||
# Methods scheduling callbacks. All these return Handles.
|
||||
@abstractmethod
|
||||
def call_soon(self, callback: Callable[..., Any], *args: Any) -> Handle: ...
|
||||
@abstractmethod
|
||||
def call_later(self, delay: float, callback: Callable[..., Any], *args: Any) -> TimerHandle: ...
|
||||
@abstractmethod
|
||||
def call_at(self, when: float, callback: Callable[..., Any], *args: Any) -> TimerHandle: ...
|
||||
@abstractmethod
|
||||
def time(self) -> float: ...
|
||||
# Future methods
|
||||
@abstractmethod
|
||||
def create_future(self) -> Future[Any]: ...
|
||||
# Tasks methods
|
||||
if sys.version_info >= (3, 8):
|
||||
@abstractmethod
|
||||
def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]], *, name: Optional[str] = ...) -> Task[_T]: ...
|
||||
else:
|
||||
@abstractmethod
|
||||
def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ...
|
||||
@abstractmethod
|
||||
def set_task_factory(
|
||||
self, factory: Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]
|
||||
) -> None: ...
|
||||
@abstractmethod
|
||||
def get_task_factory(self) -> Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]: ...
|
||||
# Methods for interacting with threads
|
||||
@abstractmethod
|
||||
def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any) -> Handle: ...
|
||||
@abstractmethod
|
||||
def run_in_executor(self, executor: Any, func: Callable[..., _T], *args: Any) -> Awaitable[_T]: ...
|
||||
@abstractmethod
|
||||
def set_default_executor(self, executor: Any) -> None: ...
|
||||
# Network I/O methods returning Futures.
|
||||
@abstractmethod
|
||||
async def getaddrinfo(
|
||||
self,
|
||||
host: Optional[str],
|
||||
port: Union[str, int, None],
|
||||
*,
|
||||
family: int = ...,
|
||||
type: int = ...,
|
||||
proto: int = ...,
|
||||
flags: int = ...,
|
||||
) -> List[Tuple[AddressFamily, SocketKind, int, str, Union[Tuple[str, int], Tuple[str, int, int, int]]]]: ...
|
||||
@abstractmethod
|
||||
async def getnameinfo(
|
||||
self, sockaddr: Union[Tuple[str, int], Tuple[str, int, int, int]], flags: int = ...
|
||||
) -> Tuple[str, str]: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
@overload
|
||||
@abstractmethod
|
||||
async def create_connection(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: str = ...,
|
||||
port: int = ...,
|
||||
*,
|
||||
ssl: _SSLContext = ...,
|
||||
family: int = ...,
|
||||
proto: int = ...,
|
||||
flags: int = ...,
|
||||
sock: None = ...,
|
||||
local_addr: Optional[Tuple[str, int]] = ...,
|
||||
server_hostname: Optional[str] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
happy_eyeballs_delay: Optional[float] = ...,
|
||||
interleave: Optional[int] = ...,
|
||||
) -> _TransProtPair: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
async def create_connection(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: None = ...,
|
||||
port: None = ...,
|
||||
*,
|
||||
ssl: _SSLContext = ...,
|
||||
family: int = ...,
|
||||
proto: int = ...,
|
||||
flags: int = ...,
|
||||
sock: socket,
|
||||
local_addr: None = ...,
|
||||
server_hostname: Optional[str] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
happy_eyeballs_delay: Optional[float] = ...,
|
||||
interleave: Optional[int] = ...,
|
||||
) -> _TransProtPair: ...
|
||||
elif sys.version_info >= (3, 7):
|
||||
@overload
|
||||
@abstractmethod
|
||||
async def create_connection(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: str = ...,
|
||||
port: int = ...,
|
||||
*,
|
||||
ssl: _SSLContext = ...,
|
||||
family: int = ...,
|
||||
proto: int = ...,
|
||||
flags: int = ...,
|
||||
sock: None = ...,
|
||||
local_addr: Optional[Tuple[str, int]] = ...,
|
||||
server_hostname: Optional[str] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
) -> _TransProtPair: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
async def create_connection(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: None = ...,
|
||||
port: None = ...,
|
||||
*,
|
||||
ssl: _SSLContext = ...,
|
||||
family: int = ...,
|
||||
proto: int = ...,
|
||||
flags: int = ...,
|
||||
sock: socket,
|
||||
local_addr: None = ...,
|
||||
server_hostname: Optional[str] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
) -> _TransProtPair: ...
|
||||
else:
|
||||
@overload
|
||||
@abstractmethod
|
||||
async def create_connection(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: str = ...,
|
||||
port: int = ...,
|
||||
*,
|
||||
ssl: _SSLContext = ...,
|
||||
family: int = ...,
|
||||
proto: int = ...,
|
||||
flags: int = ...,
|
||||
sock: None = ...,
|
||||
local_addr: Optional[Tuple[str, int]] = ...,
|
||||
server_hostname: Optional[str] = ...,
|
||||
) -> _TransProtPair: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
async def create_connection(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: None = ...,
|
||||
port: None = ...,
|
||||
*,
|
||||
ssl: _SSLContext = ...,
|
||||
family: int = ...,
|
||||
proto: int = ...,
|
||||
flags: int = ...,
|
||||
sock: socket,
|
||||
local_addr: None = ...,
|
||||
server_hostname: Optional[str] = ...,
|
||||
) -> _TransProtPair: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
@abstractmethod
|
||||
async def sock_sendfile(
|
||||
self, sock: socket, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *, fallback: bool = ...
|
||||
) -> int: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
async def create_server(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: Optional[Union[str, Sequence[str]]] = ...,
|
||||
port: int = ...,
|
||||
*,
|
||||
family: int = ...,
|
||||
flags: int = ...,
|
||||
sock: None = ...,
|
||||
backlog: int = ...,
|
||||
ssl: _SSLContext = ...,
|
||||
reuse_address: Optional[bool] = ...,
|
||||
reuse_port: Optional[bool] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
start_serving: bool = ...,
|
||||
) -> AbstractServer: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
async def create_server(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: None = ...,
|
||||
port: None = ...,
|
||||
*,
|
||||
family: int = ...,
|
||||
flags: int = ...,
|
||||
sock: socket = ...,
|
||||
backlog: int = ...,
|
||||
ssl: _SSLContext = ...,
|
||||
reuse_address: Optional[bool] = ...,
|
||||
reuse_port: Optional[bool] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
start_serving: bool = ...,
|
||||
) -> AbstractServer: ...
|
||||
async def create_unix_connection(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
path: Optional[str] = ...,
|
||||
*,
|
||||
ssl: _SSLContext = ...,
|
||||
sock: Optional[socket] = ...,
|
||||
server_hostname: Optional[str] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
) -> _TransProtPair: ...
|
||||
async def create_unix_server(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
path: Optional[str] = ...,
|
||||
*,
|
||||
sock: Optional[socket] = ...,
|
||||
backlog: int = ...,
|
||||
ssl: _SSLContext = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
start_serving: bool = ...,
|
||||
) -> AbstractServer: ...
|
||||
@abstractmethod
|
||||
async def sendfile(
|
||||
self,
|
||||
transport: BaseTransport,
|
||||
file: IO[bytes],
|
||||
offset: int = ...,
|
||||
count: Optional[int] = ...,
|
||||
*,
|
||||
fallback: bool = ...,
|
||||
) -> int: ...
|
||||
@abstractmethod
|
||||
async def start_tls(
|
||||
self,
|
||||
transport: BaseTransport,
|
||||
protocol: BaseProtocol,
|
||||
sslcontext: ssl.SSLContext,
|
||||
*,
|
||||
server_side: bool = ...,
|
||||
server_hostname: Optional[str] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
) -> BaseTransport: ...
|
||||
else:
|
||||
@overload
|
||||
@abstractmethod
|
||||
async def create_server(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: Optional[Union[str, Sequence[str]]] = ...,
|
||||
port: int = ...,
|
||||
*,
|
||||
family: int = ...,
|
||||
flags: int = ...,
|
||||
sock: None = ...,
|
||||
backlog: int = ...,
|
||||
ssl: _SSLContext = ...,
|
||||
reuse_address: Optional[bool] = ...,
|
||||
reuse_port: Optional[bool] = ...,
|
||||
) -> AbstractServer: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
async def create_server(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
host: None = ...,
|
||||
port: None = ...,
|
||||
*,
|
||||
family: int = ...,
|
||||
flags: int = ...,
|
||||
sock: socket,
|
||||
backlog: int = ...,
|
||||
ssl: _SSLContext = ...,
|
||||
reuse_address: Optional[bool] = ...,
|
||||
reuse_port: Optional[bool] = ...,
|
||||
) -> AbstractServer: ...
|
||||
async def create_unix_connection(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
path: str,
|
||||
*,
|
||||
ssl: _SSLContext = ...,
|
||||
sock: Optional[socket] = ...,
|
||||
server_hostname: Optional[str] = ...,
|
||||
) -> _TransProtPair: ...
|
||||
async def create_unix_server(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
path: str,
|
||||
*,
|
||||
sock: Optional[socket] = ...,
|
||||
backlog: int = ...,
|
||||
ssl: _SSLContext = ...,
|
||||
) -> AbstractServer: ...
|
||||
@abstractmethod
|
||||
async def create_datagram_endpoint(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
local_addr: Optional[Tuple[str, int]] = ...,
|
||||
remote_addr: Optional[Tuple[str, int]] = ...,
|
||||
*,
|
||||
family: int = ...,
|
||||
proto: int = ...,
|
||||
flags: int = ...,
|
||||
reuse_address: Optional[bool] = ...,
|
||||
reuse_port: Optional[bool] = ...,
|
||||
allow_broadcast: Optional[bool] = ...,
|
||||
sock: Optional[socket] = ...,
|
||||
) -> _TransProtPair: ...
|
||||
# Pipes and subprocesses.
|
||||
@abstractmethod
|
||||
async def connect_read_pipe(self, protocol_factory: _ProtocolFactory, pipe: Any) -> _TransProtPair: ...
|
||||
@abstractmethod
|
||||
async def connect_write_pipe(self, protocol_factory: _ProtocolFactory, pipe: Any) -> _TransProtPair: ...
|
||||
@abstractmethod
|
||||
async def subprocess_shell(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
cmd: Union[bytes, str],
|
||||
*,
|
||||
stdin: Any = ...,
|
||||
stdout: Any = ...,
|
||||
stderr: Any = ...,
|
||||
**kwargs: Any,
|
||||
) -> _TransProtPair: ...
|
||||
@abstractmethod
|
||||
async def subprocess_exec(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
*args: Any,
|
||||
stdin: Any = ...,
|
||||
stdout: Any = ...,
|
||||
stderr: Any = ...,
|
||||
**kwargs: Any,
|
||||
) -> _TransProtPair: ...
|
||||
@abstractmethod
|
||||
def add_reader(self, fd: FileDescriptorLike, callback: Callable[..., Any], *args: Any) -> None: ...
|
||||
@abstractmethod
|
||||
def remove_reader(self, fd: FileDescriptorLike) -> None: ...
|
||||
@abstractmethod
|
||||
def add_writer(self, fd: FileDescriptorLike, callback: Callable[..., Any], *args: Any) -> None: ...
|
||||
@abstractmethod
|
||||
def remove_writer(self, fd: FileDescriptorLike) -> None: ...
|
||||
# Completion based I/O methods returning Futures prior to 3.7
|
||||
if sys.version_info >= (3, 7):
|
||||
@abstractmethod
|
||||
async def sock_recv(self, sock: socket, nbytes: int) -> bytes: ...
|
||||
@abstractmethod
|
||||
async def sock_recv_into(self, sock: socket, buf: bytearray) -> int: ...
|
||||
@abstractmethod
|
||||
async def sock_sendall(self, sock: socket, data: bytes) -> None: ...
|
||||
@abstractmethod
|
||||
async def sock_connect(self, sock: socket, address: _Address) -> None: ...
|
||||
@abstractmethod
|
||||
async def sock_accept(self, sock: socket) -> Tuple[socket, _RetAddress]: ...
|
||||
else:
|
||||
@abstractmethod
|
||||
def sock_recv(self, sock: socket, nbytes: int) -> Future[bytes]: ...
|
||||
@abstractmethod
|
||||
def sock_sendall(self, sock: socket, data: bytes) -> Future[None]: ...
|
||||
@abstractmethod
|
||||
def sock_connect(self, sock: socket, address: _Address) -> Future[None]: ...
|
||||
@abstractmethod
|
||||
def sock_accept(self, sock: socket) -> Future[Tuple[socket, _RetAddress]]: ...
|
||||
# Signal handling.
|
||||
@abstractmethod
|
||||
def add_signal_handler(self, sig: int, callback: Callable[..., Any], *args: Any) -> None: ...
|
||||
@abstractmethod
|
||||
def remove_signal_handler(self, sig: int) -> None: ...
|
||||
# Error handlers.
|
||||
@abstractmethod
|
||||
def set_exception_handler(self, handler: Optional[_ExceptionHandler]) -> None: ...
|
||||
@abstractmethod
|
||||
def get_exception_handler(self) -> Optional[_ExceptionHandler]: ...
|
||||
@abstractmethod
|
||||
def default_exception_handler(self, context: _Context) -> None: ...
|
||||
@abstractmethod
|
||||
def call_exception_handler(self, context: _Context) -> None: ...
|
||||
# Debug flag management.
|
||||
@abstractmethod
|
||||
def get_debug(self) -> bool: ...
|
||||
@abstractmethod
|
||||
def set_debug(self, enabled: bool) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
@abstractmethod
|
||||
async def shutdown_default_executor(self) -> None: ...
|
||||
|
||||
class AbstractEventLoopPolicy(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def get_event_loop(self) -> AbstractEventLoop: ...
|
||||
@abstractmethod
|
||||
def set_event_loop(self, loop: Optional[AbstractEventLoop]) -> None: ...
|
||||
@abstractmethod
|
||||
def new_event_loop(self) -> AbstractEventLoop: ...
|
||||
# Child processes handling (Unix only).
|
||||
@abstractmethod
|
||||
def get_child_watcher(self) -> AbstractChildWatcher: ...
|
||||
@abstractmethod
|
||||
def set_child_watcher(self, watcher: AbstractChildWatcher) -> None: ...
|
||||
|
||||
class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy, metaclass=ABCMeta):
|
||||
def __init__(self) -> None: ...
|
||||
def get_event_loop(self) -> AbstractEventLoop: ...
|
||||
def set_event_loop(self, loop: Optional[AbstractEventLoop]) -> None: ...
|
||||
def new_event_loop(self) -> AbstractEventLoop: ...
|
||||
|
||||
def get_event_loop_policy() -> AbstractEventLoopPolicy: ...
|
||||
def set_event_loop_policy(policy: Optional[AbstractEventLoopPolicy]) -> None: ...
|
||||
def get_event_loop() -> AbstractEventLoop: ...
|
||||
def set_event_loop(loop: Optional[AbstractEventLoop]) -> None: ...
|
||||
def new_event_loop() -> AbstractEventLoop: ...
|
||||
def get_child_watcher() -> AbstractChildWatcher: ...
|
||||
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...
|
||||
def _set_running_loop(__loop: Optional[AbstractEventLoop]) -> None: ...
|
||||
def _get_running_loop() -> AbstractEventLoop: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
def get_running_loop() -> AbstractEventLoop: ...
|
||||
if sys.version_info < (3, 8):
|
||||
class SendfileNotAvailableError(RuntimeError): ...
|
||||
15
stdlib/asyncio/exceptions.pyi
Normal file
15
stdlib/asyncio/exceptions.pyi
Normal file
@@ -0,0 +1,15 @@
|
||||
import sys
|
||||
from typing import Optional
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
class CancelledError(BaseException): ...
|
||||
class TimeoutError(Exception): ...
|
||||
class InvalidStateError(Exception): ...
|
||||
class SendfileNotAvailableError(RuntimeError): ...
|
||||
class IncompleteReadError(EOFError):
|
||||
expected: Optional[int]
|
||||
partial: bytes
|
||||
def __init__(self, partial: bytes, expected: Optional[int]) -> None: ...
|
||||
class LimitOverrunError(Exception):
|
||||
consumed: int
|
||||
def __init__(self, message: str, consumed: int) -> None: ...
|
||||
20
stdlib/asyncio/format_helpers.pyi
Normal file
20
stdlib/asyncio/format_helpers.pyi
Normal file
@@ -0,0 +1,20 @@
|
||||
import functools
|
||||
import sys
|
||||
import traceback
|
||||
from types import FrameType, FunctionType
|
||||
from typing import Any, Dict, Iterable, Optional, Tuple, Union, overload
|
||||
|
||||
class _HasWrapper:
|
||||
__wrapper__: Union[_HasWrapper, FunctionType]
|
||||
|
||||
_FuncType = Union[FunctionType, _HasWrapper, functools.partial, functools.partialmethod]
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
@overload
|
||||
def _get_function_source(func: _FuncType) -> Tuple[str, int]: ...
|
||||
@overload
|
||||
def _get_function_source(func: object) -> Optional[Tuple[str, int]]: ...
|
||||
def _format_callback_source(func: object, args: Iterable[Any]) -> str: ...
|
||||
def _format_args_and_kwargs(args: Iterable[Any], kwargs: Dict[str, Any]) -> str: ...
|
||||
def _format_callback(func: object, args: Iterable[Any], kwargs: Dict[str, Any], suffix: str = ...) -> str: ...
|
||||
def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> traceback.StackSummary: ...
|
||||
65
stdlib/asyncio/futures.pyi
Normal file
65
stdlib/asyncio/futures.pyi
Normal file
@@ -0,0 +1,65 @@
|
||||
import sys
|
||||
from concurrent.futures._base import Error, Future as _ConcurrentFuture
|
||||
from typing import Any, Awaitable, Callable, Generator, Iterable, List, Optional, Tuple, TypeVar, Union
|
||||
|
||||
from .events import AbstractEventLoop
|
||||
|
||||
if sys.version_info < (3, 8):
|
||||
from concurrent.futures import CancelledError as CancelledError, TimeoutError as TimeoutError
|
||||
class InvalidStateError(Error): ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from contextvars import Context
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_S = TypeVar("_S")
|
||||
|
||||
if sys.version_info < (3, 7):
|
||||
class _TracebackLogger:
|
||||
exc: BaseException
|
||||
tb: List[str]
|
||||
def __init__(self, exc: Any, loop: AbstractEventLoop) -> None: ...
|
||||
def activate(self) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
def __del__(self) -> None: ...
|
||||
|
||||
def isfuture(obj: object) -> bool: ...
|
||||
|
||||
class Future(Awaitable[_T], Iterable[_T]):
|
||||
_state: str
|
||||
_exception: BaseException
|
||||
_blocking = False
|
||||
_log_traceback = False
|
||||
def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def __del__(self) -> None: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def get_loop(self) -> AbstractEventLoop: ...
|
||||
def _callbacks(self: _S) -> List[Tuple[Callable[[_S], Any], Context]]: ...
|
||||
def add_done_callback(self: _S, __fn: Callable[[_S], Any], *, context: Optional[Context] = ...) -> None: ...
|
||||
else:
|
||||
@property
|
||||
def _callbacks(self: _S) -> List[Callable[[_S], Any]]: ...
|
||||
def add_done_callback(self: _S, __fn: Callable[[_S], Any]) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def cancel(self, msg: Optional[str] = ...) -> bool: ...
|
||||
else:
|
||||
def cancel(self) -> bool: ...
|
||||
def cancelled(self) -> bool: ...
|
||||
def done(self) -> bool: ...
|
||||
def result(self) -> _T: ...
|
||||
def exception(self) -> Optional[BaseException]: ...
|
||||
def remove_done_callback(self: _S, __fn: Callable[[_S], Any]) -> int: ...
|
||||
def set_result(self, __result: _T) -> None: ...
|
||||
def set_exception(self, __exception: Union[type, BaseException]) -> None: ...
|
||||
def __iter__(self) -> Generator[Any, None, _T]: ...
|
||||
def __await__(self) -> Generator[Any, None, _T]: ...
|
||||
@property
|
||||
def _loop(self) -> AbstractEventLoop: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
def wrap_future(future: Union[_ConcurrentFuture[_T], Future[_T]], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...
|
||||
68
stdlib/asyncio/locks.pyi
Normal file
68
stdlib/asyncio/locks.pyi
Normal file
@@ -0,0 +1,68 @@
|
||||
import sys
|
||||
from types import TracebackType
|
||||
from typing import Any, Awaitable, Callable, Deque, Generator, Optional, Type, TypeVar, Union
|
||||
|
||||
from .events import AbstractEventLoop
|
||||
from .futures import Future
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
class _ContextManagerMixin:
|
||||
def __init__(self, lock: Union[Lock, Semaphore]) -> None: ...
|
||||
def __aenter__(self) -> Awaitable[None]: ...
|
||||
def __aexit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType]
|
||||
) -> Awaitable[None]: ...
|
||||
|
||||
else:
|
||||
class _ContextManager:
|
||||
def __init__(self, lock: Union[Lock, Semaphore]) -> None: ...
|
||||
def __enter__(self) -> object: ...
|
||||
def __exit__(self, *args: Any) -> None: ...
|
||||
class _ContextManagerMixin:
|
||||
def __init__(self, lock: Union[Lock, Semaphore]) -> None: ...
|
||||
# Apparently this exists to *prohibit* use as a context manager.
|
||||
def __enter__(self) -> object: ...
|
||||
def __exit__(self, *args: Any) -> None: ...
|
||||
def __iter__(self) -> Generator[Any, None, _ContextManager]: ...
|
||||
def __await__(self) -> Generator[Any, None, _ContextManager]: ...
|
||||
def __aenter__(self) -> Awaitable[None]: ...
|
||||
def __aexit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType]
|
||||
) -> Awaitable[None]: ...
|
||||
|
||||
class Lock(_ContextManagerMixin):
|
||||
def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
|
||||
def locked(self) -> bool: ...
|
||||
async def acquire(self) -> bool: ...
|
||||
def release(self) -> None: ...
|
||||
|
||||
class Event:
|
||||
def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
|
||||
def is_set(self) -> bool: ...
|
||||
def set(self) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
async def wait(self) -> bool: ...
|
||||
|
||||
class Condition(_ContextManagerMixin):
|
||||
def __init__(self, lock: Optional[Lock] = ..., *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
|
||||
def locked(self) -> bool: ...
|
||||
async def acquire(self) -> bool: ...
|
||||
def release(self) -> None: ...
|
||||
async def wait(self) -> bool: ...
|
||||
async def wait_for(self, predicate: Callable[[], _T]) -> _T: ...
|
||||
def notify(self, n: int = ...) -> None: ...
|
||||
def notify_all(self) -> None: ...
|
||||
|
||||
class Semaphore(_ContextManagerMixin):
|
||||
_value: int
|
||||
_waiters: Deque[Future[Any]]
|
||||
def __init__(self, value: int = ..., *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
|
||||
def locked(self) -> bool: ...
|
||||
async def acquire(self) -> bool: ...
|
||||
def release(self) -> None: ...
|
||||
def _wake_up_next(self) -> None: ...
|
||||
|
||||
class BoundedSemaphore(Semaphore):
|
||||
def __init__(self, value: int = ..., *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
|
||||
3
stdlib/asyncio/log.pyi
Normal file
3
stdlib/asyncio/log.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
import logging
|
||||
|
||||
logger: logging.Logger
|
||||
73
stdlib/asyncio/proactor_events.pyi
Normal file
73
stdlib/asyncio/proactor_events.pyi
Normal file
@@ -0,0 +1,73 @@
|
||||
from socket import socket
|
||||
from typing import Any, Mapping, Optional
|
||||
from typing_extensions import Literal
|
||||
|
||||
from . import base_events, constants, events, futures, streams, transports
|
||||
|
||||
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): ...
|
||||
|
||||
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: ...
|
||||
27
stdlib/asyncio/protocols.pyi
Normal file
27
stdlib/asyncio/protocols.pyi
Normal file
@@ -0,0 +1,27 @@
|
||||
import sys
|
||||
from asyncio import transports
|
||||
from typing import Optional, Tuple
|
||||
|
||||
class BaseProtocol:
|
||||
def connection_made(self, transport: transports.BaseTransport) -> None: ...
|
||||
def connection_lost(self, exc: Optional[Exception]) -> None: ...
|
||||
def pause_writing(self) -> None: ...
|
||||
def resume_writing(self) -> None: ...
|
||||
|
||||
class Protocol(BaseProtocol):
|
||||
def data_received(self, data: bytes) -> None: ...
|
||||
def eof_received(self) -> Optional[bool]: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
class BufferedProtocol(BaseProtocol):
|
||||
def get_buffer(self, sizehint: int) -> bytearray: ...
|
||||
def buffer_updated(self, nbytes: int) -> None: ...
|
||||
|
||||
class DatagramProtocol(BaseProtocol):
|
||||
def datagram_received(self, data: bytes, addr: Tuple[str, int]) -> None: ...
|
||||
def error_received(self, exc: Exception) -> None: ...
|
||||
|
||||
class SubprocessProtocol(BaseProtocol):
|
||||
def pipe_data_received(self, fd: int, data: bytes) -> None: ...
|
||||
def pipe_connection_lost(self, fd: int, exc: Optional[Exception]) -> None: ...
|
||||
def process_exited(self) -> None: ...
|
||||
36
stdlib/asyncio/queues.pyi
Normal file
36
stdlib/asyncio/queues.pyi
Normal file
@@ -0,0 +1,36 @@
|
||||
import sys
|
||||
from asyncio.events import AbstractEventLoop
|
||||
from typing import Any, Generic, Optional, TypeVar
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
class QueueEmpty(Exception): ...
|
||||
class QueueFull(Exception): ...
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class Queue(Generic[_T]):
|
||||
def __init__(self, maxsize: int = ..., *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
|
||||
def _init(self, maxsize: int) -> None: ...
|
||||
def _get(self) -> _T: ...
|
||||
def _put(self, item: _T) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def __str__(self) -> str: ...
|
||||
def _format(self) -> str: ...
|
||||
def qsize(self) -> int: ...
|
||||
@property
|
||||
def maxsize(self) -> int: ...
|
||||
def empty(self) -> bool: ...
|
||||
def full(self) -> bool: ...
|
||||
async def put(self, item: _T) -> None: ...
|
||||
def put_nowait(self, item: _T) -> None: ...
|
||||
async def get(self) -> _T: ...
|
||||
def get_nowait(self) -> _T: ...
|
||||
async def join(self) -> None: ...
|
||||
def task_done(self) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, type: Any) -> GenericAlias: ...
|
||||
|
||||
class PriorityQueue(Queue[_T]): ...
|
||||
class LifoQueue(Queue[_T]): ...
|
||||
10
stdlib/asyncio/runners.pyi
Normal file
10
stdlib/asyncio/runners.pyi
Normal file
@@ -0,0 +1,10 @@
|
||||
import sys
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from typing import Awaitable, Optional, TypeVar
|
||||
|
||||
_T = TypeVar("_T")
|
||||
if sys.version_info >= (3, 8):
|
||||
def run(main: Awaitable[_T], *, debug: Optional[bool] = ...) -> _T: ...
|
||||
else:
|
||||
def run(main: Awaitable[_T], *, debug: bool = ...) -> _T: ...
|
||||
7
stdlib/asyncio/selector_events.pyi
Normal file
7
stdlib/asyncio/selector_events.pyi
Normal file
@@ -0,0 +1,7 @@
|
||||
import selectors
|
||||
from typing import Optional
|
||||
|
||||
from . import base_events
|
||||
|
||||
class BaseSelectorEventLoop(base_events.BaseEventLoop):
|
||||
def __init__(self, selector: Optional[selectors.BaseSelector] = ...) -> None: ...
|
||||
133
stdlib/asyncio/sslproto.pyi
Normal file
133
stdlib/asyncio/sslproto.pyi
Normal file
@@ -0,0 +1,133 @@
|
||||
import ssl
|
||||
import sys
|
||||
from typing import Any, Callable, ClassVar, Deque, Dict, List, Optional, Tuple
|
||||
from typing_extensions import Literal
|
||||
|
||||
from . import constants, events, futures, protocols, transports
|
||||
|
||||
def _create_transport_context(server_side: bool, server_hostname: Optional[str]) -> ssl.SSLContext: ...
|
||||
|
||||
_UNWRAPPED: Literal["UNWRAPPED"]
|
||||
_DO_HANDSHAKE: Literal["DO_HANDSHAKE"]
|
||||
_WRAPPED: Literal["WRAPPED"]
|
||||
_SHUTDOWN: Literal["SHUTDOWN"]
|
||||
|
||||
class _SSLPipe:
|
||||
|
||||
max_size: ClassVar[int]
|
||||
|
||||
_context: ssl.SSLContext
|
||||
_server_side: bool
|
||||
_server_hostname: Optional[str]
|
||||
_state: str
|
||||
_incoming: ssl.MemoryBIO
|
||||
_outgoing: ssl.MemoryBIO
|
||||
_sslobj: Optional[ssl.SSLObject]
|
||||
_need_ssldata: bool
|
||||
_handshake_cb: Optional[Callable[[Optional[BaseException]], None]]
|
||||
_shutdown_cb: Optional[Callable[[], None]]
|
||||
def __init__(self, context: ssl.SSLContext, server_side: bool, server_hostname: Optional[str] = ...) -> None: ...
|
||||
@property
|
||||
def context(self) -> ssl.SSLContext: ...
|
||||
@property
|
||||
def ssl_object(self) -> Optional[ssl.SSLObject]: ...
|
||||
@property
|
||||
def need_ssldata(self) -> bool: ...
|
||||
@property
|
||||
def wrapped(self) -> bool: ...
|
||||
def do_handshake(self, callback: Optional[Callable[[Optional[BaseException]], None]] = ...) -> List[bytes]: ...
|
||||
def shutdown(self, callback: Optional[Callable[[], None]] = ...) -> List[bytes]: ...
|
||||
def feed_eof(self) -> None: ...
|
||||
def feed_ssldata(self, data: bytes, only_handshake: bool = ...) -> Tuple[List[bytes], List[bytes]]: ...
|
||||
def feed_appdata(self, data: bytes, offset: int = ...) -> Tuple[List[bytes], int]: ...
|
||||
|
||||
class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport):
|
||||
|
||||
_sendfile_compatible: ClassVar[constants._SendfileMode]
|
||||
|
||||
_loop: events.AbstractEventLoop
|
||||
_ssl_protocol: SSLProtocol
|
||||
_closed: bool
|
||||
def __init__(self, loop: events.AbstractEventLoop, ssl_protocol: SSLProtocol) -> None: ...
|
||||
def get_extra_info(self, name: str, default: Optional[Any] = ...) -> Dict[str, Any]: ...
|
||||
def set_protocol(self, protocol: protocols.BaseProtocol) -> None: ...
|
||||
def get_protocol(self) -> protocols.BaseProtocol: ...
|
||||
def is_closing(self) -> bool: ...
|
||||
def close(self) -> None: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def is_reading(self) -> bool: ...
|
||||
def pause_reading(self) -> None: ...
|
||||
def resume_reading(self) -> None: ...
|
||||
def set_write_buffer_limits(self, high: Optional[int] = ..., low: Optional[int] = ...) -> None: ...
|
||||
def get_write_buffer_size(self) -> int: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
@property
|
||||
def _protocol_paused(self) -> bool: ...
|
||||
def write(self, data: bytes) -> None: ...
|
||||
def can_write_eof(self) -> Literal[False]: ...
|
||||
def abort(self) -> None: ...
|
||||
|
||||
class SSLProtocol(protocols.Protocol):
|
||||
|
||||
_server_side: bool
|
||||
_server_hostname: Optional[str]
|
||||
_sslcontext: ssl.SSLContext
|
||||
_extra: Dict[str, Any]
|
||||
_write_backlog: Deque[Tuple[bytes, int]]
|
||||
_write_buffer_size: int
|
||||
_waiter: futures.Future[Any]
|
||||
_loop: events.AbstractEventLoop
|
||||
_app_transport: _SSLProtocolTransport
|
||||
_sslpipe: Optional[_SSLPipe]
|
||||
_session_established: bool
|
||||
_in_handshake: bool
|
||||
_in_shutdown: bool
|
||||
_transport: Optional[transports.BaseTransport]
|
||||
_call_connection_made: bool
|
||||
_ssl_handshake_timeout: Optional[int]
|
||||
_app_protocol: protocols.BaseProtocol
|
||||
_app_protocol_is_buffer: bool
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
def __init__(
|
||||
self,
|
||||
loop: events.AbstractEventLoop,
|
||||
app_protocol: protocols.BaseProtocol,
|
||||
sslcontext: ssl.SSLContext,
|
||||
waiter: futures.Future[Any],
|
||||
server_side: bool = ...,
|
||||
server_hostname: Optional[str] = ...,
|
||||
call_connection_made: bool = ...,
|
||||
ssl_handshake_timeout: Optional[int] = ...,
|
||||
) -> None: ...
|
||||
else:
|
||||
def __init__(
|
||||
self,
|
||||
loop: events.AbstractEventLoop,
|
||||
app_protocol: protocols.BaseProtocol,
|
||||
sslcontext: ssl.SSLContext,
|
||||
waiter: futures.Future,
|
||||
server_side: bool = ...,
|
||||
server_hostname: Optional[str] = ...,
|
||||
call_connection_made: bool = ...,
|
||||
) -> None: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def _set_app_protocol(self, app_protocol: protocols.BaseProtocol) -> None: ...
|
||||
def _wakeup_waiter(self, exc: Optional[BaseException] = ...) -> None: ...
|
||||
def connection_made(self, transport: transports.BaseTransport) -> None: ...
|
||||
def connection_lost(self, exc: Optional[BaseException]) -> None: ...
|
||||
def pause_writing(self) -> None: ...
|
||||
def resume_writing(self) -> None: ...
|
||||
def data_received(self, data: bytes) -> None: ...
|
||||
def eof_received(self) -> None: ...
|
||||
def _get_extra_info(self, name: str, default: Optional[Any] = ...) -> Any: ...
|
||||
def _start_shutdown(self) -> None: ...
|
||||
def _write_appdata(self, data: bytes) -> None: ...
|
||||
def _start_handshake(self) -> None: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def _check_handshake_timeout(self) -> None: ...
|
||||
def _on_handshake_complete(self, handshake_exc: Optional[BaseException]) -> None: ...
|
||||
def _process_write_backlog(self) -> None: ...
|
||||
def _fatal_error(self, exc: BaseException, message: str = ...) -> None: ...
|
||||
def _finalize(self) -> None: ...
|
||||
def _abort(self) -> None: ...
|
||||
12
stdlib/asyncio/staggered.pyi
Normal file
12
stdlib/asyncio/staggered.pyi
Normal file
@@ -0,0 +1,12 @@
|
||||
import sys
|
||||
from typing import Any, Awaitable, Callable, Iterable, List, Optional, Tuple
|
||||
|
||||
from . import events
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
async def staggered_race(
|
||||
coro_fns: Iterable[Callable[[], Awaitable[Any]]],
|
||||
delay: Optional[float],
|
||||
*,
|
||||
loop: Optional[events.AbstractEventLoop] = ...,
|
||||
) -> Tuple[Any, Optional[int], List[Optional[Exception]]]: ...
|
||||
104
stdlib/asyncio/streams.pyi
Normal file
104
stdlib/asyncio/streams.pyi
Normal file
@@ -0,0 +1,104 @@
|
||||
import sys
|
||||
from typing import Any, AsyncIterator, Awaitable, Callable, Iterable, Optional, Tuple, Union
|
||||
|
||||
from . import events, protocols, transports
|
||||
|
||||
_ClientConnectedCallback = Callable[[StreamReader, StreamWriter], Optional[Awaitable[None]]]
|
||||
|
||||
if sys.version_info < (3, 8):
|
||||
class IncompleteReadError(EOFError):
|
||||
expected: Optional[int]
|
||||
partial: bytes
|
||||
def __init__(self, partial: bytes, expected: Optional[int]) -> None: ...
|
||||
class LimitOverrunError(Exception):
|
||||
consumed: int
|
||||
def __init__(self, message: str, consumed: int) -> None: ...
|
||||
|
||||
async def open_connection(
|
||||
host: Optional[str] = ...,
|
||||
port: Optional[Union[int, str]] = ...,
|
||||
*,
|
||||
loop: Optional[events.AbstractEventLoop] = ...,
|
||||
limit: int = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
**kwds: Any,
|
||||
) -> Tuple[StreamReader, StreamWriter]: ...
|
||||
async def start_server(
|
||||
client_connected_cb: _ClientConnectedCallback,
|
||||
host: Optional[str] = ...,
|
||||
port: Optional[Union[int, str]] = ...,
|
||||
*,
|
||||
loop: Optional[events.AbstractEventLoop] = ...,
|
||||
limit: int = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
**kwds: Any,
|
||||
) -> events.AbstractServer: ...
|
||||
|
||||
if sys.platform != "win32":
|
||||
if sys.version_info >= (3, 7):
|
||||
from os import PathLike
|
||||
|
||||
_PathType = Union[str, PathLike[str]]
|
||||
else:
|
||||
_PathType = str
|
||||
async def open_unix_connection(
|
||||
path: Optional[_PathType] = ..., *, loop: Optional[events.AbstractEventLoop] = ..., limit: int = ..., **kwds: Any
|
||||
) -> Tuple[StreamReader, StreamWriter]: ...
|
||||
async def start_unix_server(
|
||||
client_connected_cb: _ClientConnectedCallback,
|
||||
path: Optional[_PathType] = ...,
|
||||
*,
|
||||
loop: Optional[events.AbstractEventLoop] = ...,
|
||||
limit: int = ...,
|
||||
**kwds: Any,
|
||||
) -> events.AbstractServer: ...
|
||||
|
||||
class FlowControlMixin(protocols.Protocol): ...
|
||||
|
||||
class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
|
||||
def __init__(
|
||||
self,
|
||||
stream_reader: StreamReader,
|
||||
client_connected_cb: Optional[_ClientConnectedCallback] = ...,
|
||||
loop: Optional[events.AbstractEventLoop] = ...,
|
||||
) -> None: ...
|
||||
def connection_made(self, transport: transports.BaseTransport) -> None: ...
|
||||
def connection_lost(self, exc: Optional[Exception]) -> None: ...
|
||||
def data_received(self, data: bytes) -> None: ...
|
||||
def eof_received(self) -> bool: ...
|
||||
|
||||
class StreamWriter:
|
||||
def __init__(
|
||||
self,
|
||||
transport: transports.BaseTransport,
|
||||
protocol: protocols.BaseProtocol,
|
||||
reader: Optional[StreamReader],
|
||||
loop: events.AbstractEventLoop,
|
||||
) -> None: ...
|
||||
@property
|
||||
def transport(self) -> transports.BaseTransport: ...
|
||||
def write(self, data: bytes) -> None: ...
|
||||
def writelines(self, data: Iterable[bytes]) -> None: ...
|
||||
def write_eof(self) -> None: ...
|
||||
def can_write_eof(self) -> bool: ...
|
||||
def close(self) -> None: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def is_closing(self) -> bool: ...
|
||||
async def wait_closed(self) -> None: ...
|
||||
def get_extra_info(self, name: str, default: Any = ...) -> Any: ...
|
||||
async def drain(self) -> None: ...
|
||||
|
||||
class StreamReader:
|
||||
def __init__(self, limit: int = ..., loop: Optional[events.AbstractEventLoop] = ...) -> None: ...
|
||||
def exception(self) -> Exception: ...
|
||||
def set_exception(self, exc: Exception) -> None: ...
|
||||
def set_transport(self, transport: transports.BaseTransport) -> None: ...
|
||||
def feed_eof(self) -> None: ...
|
||||
def at_eof(self) -> bool: ...
|
||||
def feed_data(self, data: bytes) -> None: ...
|
||||
async def readline(self) -> bytes: ...
|
||||
async def readuntil(self, separator: bytes = ...) -> bytes: ...
|
||||
async def read(self, n: int = ...) -> bytes: ...
|
||||
async def readexactly(self, n: int) -> bytes: ...
|
||||
def __aiter__(self) -> AsyncIterator[bytes]: ...
|
||||
async def __anext__(self) -> bytes: ...
|
||||
60
stdlib/asyncio/subprocess.pyi
Normal file
60
stdlib/asyncio/subprocess.pyi
Normal file
@@ -0,0 +1,60 @@
|
||||
import sys
|
||||
from asyncio import events, protocols, streams, transports
|
||||
from typing import IO, Any, Optional, Tuple, Union
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from os import PathLike
|
||||
|
||||
_ExecArg = Union[str, bytes, PathLike[str], PathLike[bytes]]
|
||||
else:
|
||||
_ExecArg = Union[str, bytes] # Union used instead of AnyStr due to mypy issue #1236
|
||||
|
||||
PIPE: int
|
||||
STDOUT: int
|
||||
DEVNULL: int
|
||||
|
||||
class SubprocessStreamProtocol(streams.FlowControlMixin, protocols.SubprocessProtocol):
|
||||
stdin: Optional[streams.StreamWriter]
|
||||
stdout: Optional[streams.StreamReader]
|
||||
stderr: Optional[streams.StreamReader]
|
||||
def __init__(self, limit: int, loop: events.AbstractEventLoop) -> None: ...
|
||||
def connection_made(self, transport: transports.BaseTransport) -> None: ...
|
||||
def pipe_data_received(self, fd: int, data: Union[bytes, str]) -> None: ...
|
||||
def pipe_connection_lost(self, fd: int, exc: Optional[Exception]) -> None: ...
|
||||
def process_exited(self) -> None: ...
|
||||
|
||||
class Process:
|
||||
stdin: Optional[streams.StreamWriter]
|
||||
stdout: Optional[streams.StreamReader]
|
||||
stderr: Optional[streams.StreamReader]
|
||||
pid: int
|
||||
def __init__(
|
||||
self, transport: transports.BaseTransport, protocol: protocols.BaseProtocol, loop: events.AbstractEventLoop
|
||||
) -> None: ...
|
||||
@property
|
||||
def returncode(self) -> Optional[int]: ...
|
||||
async def wait(self) -> int: ...
|
||||
def send_signal(self, signal: int) -> None: ...
|
||||
def terminate(self) -> None: ...
|
||||
def kill(self) -> None: ...
|
||||
async def communicate(self, input: Optional[bytes] = ...) -> Tuple[bytes, bytes]: ...
|
||||
|
||||
async def create_subprocess_shell(
|
||||
cmd: Union[str, bytes], # Union used instead of AnyStr due to mypy issue #1236
|
||||
stdin: Union[int, IO[Any], None] = ...,
|
||||
stdout: Union[int, IO[Any], None] = ...,
|
||||
stderr: Union[int, IO[Any], None] = ...,
|
||||
loop: Optional[events.AbstractEventLoop] = ...,
|
||||
limit: int = ...,
|
||||
**kwds: Any,
|
||||
) -> Process: ...
|
||||
async def create_subprocess_exec(
|
||||
program: _ExecArg,
|
||||
*args: _ExecArg,
|
||||
stdin: Union[int, IO[Any], None] = ...,
|
||||
stdout: Union[int, IO[Any], None] = ...,
|
||||
stderr: Union[int, IO[Any], None] = ...,
|
||||
loop: Optional[events.AbstractEventLoop] = ...,
|
||||
limit: int = ...,
|
||||
**kwds: Any,
|
||||
) -> Process: ...
|
||||
209
stdlib/asyncio/tasks.pyi
Normal file
209
stdlib/asyncio/tasks.pyi
Normal file
@@ -0,0 +1,209 @@
|
||||
import concurrent.futures
|
||||
import sys
|
||||
from types import FrameType
|
||||
from typing import (
|
||||
Any,
|
||||
Awaitable,
|
||||
Generator,
|
||||
Generic,
|
||||
Iterable,
|
||||
Iterator,
|
||||
List,
|
||||
Optional,
|
||||
Set,
|
||||
TextIO,
|
||||
Tuple,
|
||||
TypeVar,
|
||||
Union,
|
||||
overload,
|
||||
)
|
||||
from typing_extensions import Literal
|
||||
|
||||
from .events import AbstractEventLoop
|
||||
from .futures import Future
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_T1 = TypeVar("_T1")
|
||||
_T2 = TypeVar("_T2")
|
||||
_T3 = TypeVar("_T3")
|
||||
_T4 = TypeVar("_T4")
|
||||
_T5 = TypeVar("_T5")
|
||||
_FutureT = Union[Future[_T], Generator[Any, None, _T], Awaitable[_T]]
|
||||
_TaskYieldType = Optional[Future[object]]
|
||||
|
||||
FIRST_EXCEPTION: str
|
||||
FIRST_COMPLETED: str
|
||||
ALL_COMPLETED: str
|
||||
|
||||
def as_completed(
|
||||
fs: Iterable[_FutureT[_T]], *, loop: Optional[AbstractEventLoop] = ..., timeout: Optional[float] = ...
|
||||
) -> Iterator[Future[_T]]: ...
|
||||
def ensure_future(coro_or_future: _FutureT[_T], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...
|
||||
|
||||
# Prior to Python 3.7 'async' was an alias for 'ensure_future'.
|
||||
# It became a keyword in 3.7.
|
||||
|
||||
# `gather()` actually returns a list with length equal to the number
|
||||
# of tasks passed; however, Tuple is used similar to the annotation for
|
||||
# zip() because typing does not support variadic type variables. See
|
||||
# typing PR #1550 for discussion.
|
||||
@overload
|
||||
def gather(
|
||||
coro_or_future1: _FutureT[_T1], *, loop: Optional[AbstractEventLoop] = ..., return_exceptions: Literal[False] = ...
|
||||
) -> Future[Tuple[_T1]]: ...
|
||||
@overload
|
||||
def gather(
|
||||
coro_or_future1: _FutureT[_T1],
|
||||
coro_or_future2: _FutureT[_T2],
|
||||
*,
|
||||
loop: Optional[AbstractEventLoop] = ...,
|
||||
return_exceptions: Literal[False] = ...,
|
||||
) -> Future[Tuple[_T1, _T2]]: ...
|
||||
@overload
|
||||
def gather(
|
||||
coro_or_future1: _FutureT[_T1],
|
||||
coro_or_future2: _FutureT[_T2],
|
||||
coro_or_future3: _FutureT[_T3],
|
||||
*,
|
||||
loop: Optional[AbstractEventLoop] = ...,
|
||||
return_exceptions: Literal[False] = ...,
|
||||
) -> Future[Tuple[_T1, _T2, _T3]]: ...
|
||||
@overload
|
||||
def gather(
|
||||
coro_or_future1: _FutureT[_T1],
|
||||
coro_or_future2: _FutureT[_T2],
|
||||
coro_or_future3: _FutureT[_T3],
|
||||
coro_or_future4: _FutureT[_T4],
|
||||
*,
|
||||
loop: Optional[AbstractEventLoop] = ...,
|
||||
return_exceptions: Literal[False] = ...,
|
||||
) -> Future[Tuple[_T1, _T2, _T3, _T4]]: ...
|
||||
@overload
|
||||
def gather(
|
||||
coro_or_future1: _FutureT[_T1],
|
||||
coro_or_future2: _FutureT[_T2],
|
||||
coro_or_future3: _FutureT[_T3],
|
||||
coro_or_future4: _FutureT[_T4],
|
||||
coro_or_future5: _FutureT[_T5],
|
||||
*,
|
||||
loop: Optional[AbstractEventLoop] = ...,
|
||||
return_exceptions: Literal[False] = ...,
|
||||
) -> Future[Tuple[_T1, _T2, _T3, _T4, _T5]]: ...
|
||||
@overload
|
||||
def gather(
|
||||
coro_or_future1: _FutureT[Any],
|
||||
coro_or_future2: _FutureT[Any],
|
||||
coro_or_future3: _FutureT[Any],
|
||||
coro_or_future4: _FutureT[Any],
|
||||
coro_or_future5: _FutureT[Any],
|
||||
coro_or_future6: _FutureT[Any],
|
||||
*coros_or_futures: _FutureT[Any],
|
||||
loop: Optional[AbstractEventLoop] = ...,
|
||||
return_exceptions: bool = ...,
|
||||
) -> Future[List[Any]]: ...
|
||||
@overload
|
||||
def gather(
|
||||
coro_or_future1: _FutureT[_T1], *, loop: Optional[AbstractEventLoop] = ..., return_exceptions: bool = ...
|
||||
) -> Future[Tuple[Union[_T1, BaseException]]]: ...
|
||||
@overload
|
||||
def gather(
|
||||
coro_or_future1: _FutureT[_T1],
|
||||
coro_or_future2: _FutureT[_T2],
|
||||
*,
|
||||
loop: Optional[AbstractEventLoop] = ...,
|
||||
return_exceptions: bool = ...,
|
||||
) -> Future[Tuple[Union[_T1, BaseException], Union[_T2, BaseException]]]: ...
|
||||
@overload
|
||||
def gather(
|
||||
coro_or_future1: _FutureT[_T1],
|
||||
coro_or_future2: _FutureT[_T2],
|
||||
coro_or_future3: _FutureT[_T3],
|
||||
*,
|
||||
loop: Optional[AbstractEventLoop] = ...,
|
||||
return_exceptions: bool = ...,
|
||||
) -> Future[Tuple[Union[_T1, BaseException], Union[_T2, BaseException], Union[_T3, BaseException]]]: ...
|
||||
@overload
|
||||
def gather(
|
||||
coro_or_future1: _FutureT[_T1],
|
||||
coro_or_future2: _FutureT[_T2],
|
||||
coro_or_future3: _FutureT[_T3],
|
||||
coro_or_future4: _FutureT[_T4],
|
||||
*,
|
||||
loop: Optional[AbstractEventLoop] = ...,
|
||||
return_exceptions: bool = ...,
|
||||
) -> Future[
|
||||
Tuple[Union[_T1, BaseException], Union[_T2, BaseException], Union[_T3, BaseException], Union[_T4, BaseException]]
|
||||
]: ...
|
||||
@overload
|
||||
def gather(
|
||||
coro_or_future1: _FutureT[_T1],
|
||||
coro_or_future2: _FutureT[_T2],
|
||||
coro_or_future3: _FutureT[_T3],
|
||||
coro_or_future4: _FutureT[_T4],
|
||||
coro_or_future5: _FutureT[_T5],
|
||||
*,
|
||||
loop: Optional[AbstractEventLoop] = ...,
|
||||
return_exceptions: bool = ...,
|
||||
) -> Future[
|
||||
Tuple[
|
||||
Union[_T1, BaseException],
|
||||
Union[_T2, BaseException],
|
||||
Union[_T3, BaseException],
|
||||
Union[_T4, BaseException],
|
||||
Union[_T5, BaseException],
|
||||
]
|
||||
]: ...
|
||||
def run_coroutine_threadsafe(coro: _FutureT[_T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ...
|
||||
def shield(arg: _FutureT[_T], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...
|
||||
def sleep(delay: float, result: _T = ..., *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...
|
||||
def wait(
|
||||
fs: Iterable[_FutureT[_T]], *, loop: Optional[AbstractEventLoop] = ..., timeout: Optional[float] = ..., return_when: str = ...
|
||||
) -> Future[Tuple[Set[Future[_T]], Set[Future[_T]]]]: ...
|
||||
def wait_for(fut: _FutureT[_T], timeout: Optional[float], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...
|
||||
|
||||
class Task(Future[_T], Generic[_T]):
|
||||
if sys.version_info >= (3, 8):
|
||||
def __init__(
|
||||
self,
|
||||
coro: Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]],
|
||||
*,
|
||||
loop: AbstractEventLoop = ...,
|
||||
name: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
else:
|
||||
def __init__(
|
||||
self, coro: Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]], *, loop: AbstractEventLoop = ...
|
||||
) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def get_coro(self) -> Any: ...
|
||||
def get_name(self) -> str: ...
|
||||
def set_name(self, __value: object) -> None: ...
|
||||
def get_stack(self, *, limit: int = ...) -> List[FrameType]: ...
|
||||
def print_stack(self, *, limit: int = ..., file: TextIO = ...) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def cancel(self, msg: Optional[str] = ...) -> bool: ...
|
||||
else:
|
||||
def cancel(self) -> bool: ...
|
||||
if sys.version_info < (3, 9):
|
||||
@classmethod
|
||||
def current_task(cls, loop: Optional[AbstractEventLoop] = ...) -> Optional[Task[Any]]: ...
|
||||
@classmethod
|
||||
def all_tasks(cls, loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ...
|
||||
if sys.version_info < (3, 7):
|
||||
def _wakeup(self, fut: Future[Any]) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
def all_tasks(loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def create_task(
|
||||
coro: Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]], *, name: Optional[str] = ...
|
||||
) -> Task[_T]: ...
|
||||
else:
|
||||
def create_task(coro: Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]]) -> Task[_T]: ...
|
||||
def current_task(loop: Optional[AbstractEventLoop] = ...) -> Optional[Task[Any]]: ...
|
||||
7
stdlib/asyncio/threads.pyi
Normal file
7
stdlib/asyncio/threads.pyi
Normal file
@@ -0,0 +1,7 @@
|
||||
import sys
|
||||
from typing import Any, Callable, TypeVar
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
async def to_thread(__func: Callable[..., _T], *args: Any, **kwargs: Any) -> _T: ...
|
||||
46
stdlib/asyncio/transports.pyi
Normal file
46
stdlib/asyncio/transports.pyi
Normal file
@@ -0,0 +1,46 @@
|
||||
import sys
|
||||
from asyncio.events import AbstractEventLoop
|
||||
from asyncio.protocols import BaseProtocol
|
||||
from socket import _Address
|
||||
from typing import Any, List, Mapping, Optional, Tuple
|
||||
|
||||
class BaseTransport:
|
||||
def __init__(self, extra: Optional[Mapping[Any, Any]] = ...) -> None: ...
|
||||
def get_extra_info(self, name: Any, default: Any = ...) -> Any: ...
|
||||
def is_closing(self) -> bool: ...
|
||||
def close(self) -> None: ...
|
||||
def set_protocol(self, protocol: BaseProtocol) -> None: ...
|
||||
def get_protocol(self) -> BaseProtocol: ...
|
||||
|
||||
class ReadTransport(BaseTransport):
|
||||
if sys.version_info >= (3, 7):
|
||||
def is_reading(self) -> bool: ...
|
||||
def pause_reading(self) -> None: ...
|
||||
def resume_reading(self) -> None: ...
|
||||
|
||||
class WriteTransport(BaseTransport):
|
||||
def set_write_buffer_limits(self, high: Optional[int] = ..., low: Optional[int] = ...) -> None: ...
|
||||
def get_write_buffer_size(self) -> int: ...
|
||||
def write(self, data: Any) -> None: ...
|
||||
def writelines(self, list_of_data: List[Any]) -> None: ...
|
||||
def write_eof(self) -> None: ...
|
||||
def can_write_eof(self) -> bool: ...
|
||||
def abort(self) -> None: ...
|
||||
|
||||
class Transport(ReadTransport, WriteTransport): ...
|
||||
|
||||
class DatagramTransport(BaseTransport):
|
||||
def sendto(self, data: Any, addr: Optional[_Address] = ...) -> None: ...
|
||||
def abort(self) -> None: ...
|
||||
|
||||
class SubprocessTransport(BaseTransport):
|
||||
def get_pid(self) -> int: ...
|
||||
def get_returncode(self) -> Optional[int]: ...
|
||||
def get_pipe_transport(self, fd: int) -> Optional[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]: ...
|
||||
86
stdlib/asyncio/trsock.pyi
Normal file
86
stdlib/asyncio/trsock.pyi
Normal file
@@ -0,0 +1,86 @@
|
||||
import socket
|
||||
import sys
|
||||
from types import TracebackType
|
||||
from typing import Any, BinaryIO, Iterable, List, NoReturn, Optional, Tuple, Type, Union, overload
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
# These are based in socket, maybe move them out into _typeshed.pyi or such
|
||||
_Address = Union[tuple, str]
|
||||
_RetAddress = Any
|
||||
_WriteBuffer = Union[bytearray, memoryview]
|
||||
_CMSG = Tuple[int, int, bytes]
|
||||
class TransportSocket:
|
||||
def __init__(self, sock: socket.socket) -> None: ...
|
||||
def _na(self, what: str) -> None: ...
|
||||
@property
|
||||
def family(self) -> int: ...
|
||||
@property
|
||||
def type(self) -> int: ...
|
||||
@property
|
||||
def proto(self) -> int: ...
|
||||
def __getstate__(self) -> NoReturn: ...
|
||||
def fileno(self) -> int: ...
|
||||
def dup(self) -> socket.socket: ...
|
||||
def get_inheritable(self) -> bool: ...
|
||||
def shutdown(self, how: int) -> None: ...
|
||||
@overload
|
||||
def getsockopt(self, level: int, optname: int) -> int: ...
|
||||
@overload
|
||||
def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ...
|
||||
@overload
|
||||
def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ...
|
||||
@overload
|
||||
def setsockopt(self, level: int, optname: int, value: None, optlen: int) -> None: ...
|
||||
def getpeername(self) -> _RetAddress: ...
|
||||
def getsockname(self) -> _RetAddress: ...
|
||||
def getsockbyname(self) -> NoReturn: ... # This method doesn't exist on socket, yet is passed through?
|
||||
def accept(self) -> Tuple[socket.socket, _RetAddress]: ...
|
||||
def connect(self, address: Union[_Address, bytes]) -> None: ...
|
||||
def connect_ex(self, address: Union[_Address, bytes]) -> int: ...
|
||||
def bind(self, address: Union[_Address, bytes]) -> None: ...
|
||||
if sys.platform == "win32":
|
||||
def ioctl(self, control: int, option: Union[int, Tuple[int, int, int], bool]) -> None: ...
|
||||
else:
|
||||
def ioctl(self, control: int, option: Union[int, Tuple[int, int, int], bool]) -> NoReturn: ...
|
||||
def listen(self, __backlog: int = ...) -> None: ...
|
||||
def makefile(self) -> BinaryIO: ...
|
||||
def sendfile(self, file: BinaryIO, offset: int = ..., count: Optional[int] = ...) -> int: ...
|
||||
def close(self) -> None: ...
|
||||
def detach(self) -> int: ...
|
||||
if sys.platform == "linux":
|
||||
def sendmsg_afalg(
|
||||
self, msg: Iterable[bytes] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ...
|
||||
) -> int: ...
|
||||
else:
|
||||
def sendmsg_afalg(
|
||||
self, msg: Iterable[bytes] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ...
|
||||
) -> NoReturn: ...
|
||||
def sendmsg(
|
||||
self, __buffers: Iterable[bytes], __ancdata: Iterable[_CMSG] = ..., __flags: int = ..., __address: _Address = ...
|
||||
) -> int: ...
|
||||
@overload
|
||||
def sendto(self, data: bytes, address: _Address) -> int: ...
|
||||
@overload
|
||||
def sendto(self, data: bytes, flags: int, address: _Address) -> int: ...
|
||||
def send(self, data: bytes, flags: int = ...) -> int: ...
|
||||
def sendall(self, data: bytes, flags: int = ...) -> None: ...
|
||||
def set_inheritable(self, inheritable: bool) -> None: ...
|
||||
if sys.platform == "win32":
|
||||
def share(self, process_id: int) -> bytes: ...
|
||||
else:
|
||||
def share(self, process_id: int) -> NoReturn: ...
|
||||
def recv_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> int: ...
|
||||
def recvfrom_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> Tuple[int, _RetAddress]: ...
|
||||
def recvmsg_into(
|
||||
self, __buffers: Iterable[_WriteBuffer], __ancbufsize: int = ..., __flags: int = ...
|
||||
) -> Tuple[int, List[_CMSG], int, Any]: ...
|
||||
def recvmsg(self, __bufsize: int, __ancbufsize: int = ..., __flags: int = ...) -> Tuple[bytes, List[_CMSG], int, Any]: ...
|
||||
def recvfrom(self, bufsize: int, flags: int = ...) -> Tuple[bytes, _RetAddress]: ...
|
||||
def recv(self, bufsize: int, flags: int = ...) -> bytes: ...
|
||||
def settimeout(self, value: Optional[float]) -> None: ...
|
||||
def gettimeout(self) -> Optional[float]: ...
|
||||
def setblocking(self, flag: bool) -> None: ...
|
||||
def __enter__(self) -> socket.socket: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
|
||||
) -> None: ...
|
||||
57
stdlib/asyncio/unix_events.pyi
Normal file
57
stdlib/asyncio/unix_events.pyi
Normal file
@@ -0,0 +1,57 @@
|
||||
import sys
|
||||
import types
|
||||
from typing import Any, Callable, Optional, Type, TypeVar
|
||||
|
||||
from .events import AbstractEventLoop, BaseDefaultEventLoopPolicy
|
||||
from .selector_events import BaseSelectorEventLoop
|
||||
|
||||
_T1 = TypeVar("_T1", bound=AbstractChildWatcher)
|
||||
_T2 = TypeVar("_T2", bound=SafeChildWatcher)
|
||||
_T3 = TypeVar("_T3", bound=FastChildWatcher)
|
||||
|
||||
class AbstractChildWatcher:
|
||||
def add_child_handler(self, pid: int, callback: Callable[..., Any], *args: Any) -> None: ...
|
||||
def remove_child_handler(self, pid: int) -> bool: ...
|
||||
def attach_loop(self, loop: Optional[AbstractEventLoop]) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def __enter__(self: _T1) -> _T1: ...
|
||||
def __exit__(
|
||||
self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType]
|
||||
) -> None: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def is_active(self) -> bool: ...
|
||||
|
||||
class BaseChildWatcher(AbstractChildWatcher):
|
||||
def __init__(self) -> None: ...
|
||||
|
||||
class SafeChildWatcher(BaseChildWatcher):
|
||||
def __enter__(self: _T2) -> _T2: ...
|
||||
|
||||
class FastChildWatcher(BaseChildWatcher):
|
||||
def __enter__(self: _T3) -> _T3: ...
|
||||
|
||||
class _UnixSelectorEventLoop(BaseSelectorEventLoop): ...
|
||||
|
||||
class _UnixDefaultEventLoopPolicy(BaseDefaultEventLoopPolicy):
|
||||
def get_child_watcher(self) -> AbstractChildWatcher: ...
|
||||
def set_child_watcher(self, watcher: Optional[AbstractChildWatcher]) -> None: ...
|
||||
|
||||
SelectorEventLoop = _UnixSelectorEventLoop
|
||||
|
||||
DefaultEventLoopPolicy = _UnixDefaultEventLoopPolicy
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
|
||||
from typing import Protocol
|
||||
|
||||
_T4 = TypeVar("_T4", bound=MultiLoopChildWatcher)
|
||||
_T5 = TypeVar("_T5", bound=ThreadedChildWatcher)
|
||||
class _Warn(Protocol):
|
||||
def __call__(
|
||||
self, message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ..., source: Optional[Any] = ...
|
||||
) -> None: ...
|
||||
class MultiLoopChildWatcher(AbstractChildWatcher):
|
||||
def __enter__(self: _T4) -> _T4: ...
|
||||
class ThreadedChildWatcher(AbstractChildWatcher):
|
||||
def __enter__(self: _T5) -> _T5: ...
|
||||
def __del__(self, _warn: _Warn = ...) -> None: ...
|
||||
76
stdlib/asyncio/windows_events.pyi
Normal file
76
stdlib/asyncio/windows_events.pyi
Normal file
@@ -0,0 +1,76 @@
|
||||
import socket
|
||||
import sys
|
||||
from typing import IO, Any, Callable, ClassVar, List, NoReturn, Optional, Tuple, Type
|
||||
|
||||
from . import events, futures, proactor_events, selector_events, streams, windows_utils
|
||||
|
||||
__all__ = [
|
||||
"SelectorEventLoop",
|
||||
"ProactorEventLoop",
|
||||
"IocpProactor",
|
||||
"DefaultEventLoopPolicy",
|
||||
"WindowsSelectorEventLoopPolicy",
|
||||
"WindowsProactorEventLoopPolicy",
|
||||
]
|
||||
|
||||
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]: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
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]: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
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: Optional[int] = ...) -> bool: ...
|
||||
def close(self) -> None: ...
|
||||
|
||||
SelectorEventLoop = _WindowsSelectorEventLoop
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
|
||||
_loop_factory: ClassVar[Type[SelectorEventLoop]]
|
||||
def get_child_watcher(self) -> NoReturn: ...
|
||||
def set_child_watcher(self, watcher: Any) -> NoReturn: ...
|
||||
class WindowsProactorEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
|
||||
_loop_factory: ClassVar[Type[ProactorEventLoop]]
|
||||
def get_child_watcher(self) -> NoReturn: ...
|
||||
def set_child_watcher(self, watcher: Any) -> NoReturn: ...
|
||||
DefaultEventLoopPolicy = WindowsSelectorEventLoopPolicy
|
||||
else:
|
||||
class _WindowsDefaultEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
|
||||
_loop_factory: ClassVar[Type[SelectorEventLoop]]
|
||||
def get_child_watcher(self) -> NoReturn: ...
|
||||
def set_child_watcher(self, watcher: Any) -> NoReturn: ...
|
||||
DefaultEventLoopPolicy = _WindowsDefaultEventLoopPolicy
|
||||
26
stdlib/asyncio/windows_utils.pyi
Normal file
26
stdlib/asyncio/windows_utils.pyi
Normal file
@@ -0,0 +1,26 @@
|
||||
import sys
|
||||
from types import TracebackType
|
||||
from typing import Callable, Optional, Protocol, Tuple, Type
|
||||
|
||||
class _WarnFunction(Protocol):
|
||||
def __call__(self, message: str, category: Type[Warning] = ..., stacklevel: int = ..., source: PipeHandle = ...) -> None: ...
|
||||
|
||||
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: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def __del__(self, _warn: _WarnFunction = ...) -> None: ...
|
||||
else:
|
||||
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: ...
|
||||
Reference in New Issue
Block a user