Add missing asyncio modules (#4149)

This commit is contained in:
Rune Tynan
2020-05-31 20:05:16 -04:00
committed by GitHub
parent 2137026681
commit 342ce69f88
14 changed files with 368 additions and 3 deletions

View File

@@ -0,0 +1,18 @@
import sys
import contextvars
from typing import List, Tuple, Callable, Sequence
from . import futures
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
_PENDING: Literal["PENDING"] # undocumented
_CANCELLED: Literal["CANCELLED"] # undocumented
_FINISHED: Literal["FINISHED"] # undocumented
def isfuture(obj: object) -> bool: ...
def _format_callbacks(cb: Sequence[Tuple[Callable[[futures.Future], None], contextvars.Context]]) -> str: ... # undocumented
def _future_repr_info(future: futures.Future) -> List[str]: ... # undocumented

View File

@@ -0,0 +1,59 @@
from typing import Optional, Union, Sequence, IO, Any, List, Deque, Dict, Tuple, Callable
import subprocess
from . import events
from . import protocols
from . import futures
from . import 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] # undocumented
_pid: Optional[int] # undocumented
_returncode: Optional[int] # undocumented
_exit_waiters: List[futures.Future] # 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] = ..., 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): ... # 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]) -> 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: ...

View File

@@ -0,0 +1,16 @@
import sys
from typing import List, Optional, Union
from types import FrameType
from . import tasks
if sys.version_info >= (3, 6):
from builtins import _PathLike
_PathType = Union[bytes, str, _PathLike]
else:
_PathType = Union[bytes, str]
def _task_repr_info(task: tasks.Task) -> List[str]: ... # undocumented
def _task_get_stack(task: tasks.Task, limit: Optional[int]) -> List[FrameType]: ... # undocumented
def _task_print_stack(task: tasks.Task, limit: Optional[int], file: _PathType): ... # undocumented

View File

@@ -0,0 +1,10 @@
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: ...

View File

@@ -0,0 +1,25 @@
import sys
import functools
import traceback
from typing import Optional, Tuple, Union, Iterable, Dict, Any, overload
from types import FunctionType, FrameType
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: ...

4
stdlib/3/asyncio/log.pyi Normal file
View File

@@ -0,0 +1,4 @@
import logging
logger: logging.Logger

View File

@@ -0,0 +1,135 @@
import sys
import ssl
from typing import ClassVar, Optional, List, Tuple, Callable, Dict, Any, Deque
from . import transports
from . import constants
from . import events
from . import protocols
from . import futures
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
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
if sys.version_info >= (3, 6):
def __init__(self, loop: events.AbstractEventLoop, ssl_protocol: SSLProtocol) -> None: ...
else:
def __init__(self, loop: events.AbstractEventLoop, ssl_protocol: SSLProtocol, app_protocol: protocols.BaseProtocol) -> 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
_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,
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: ...

View File

@@ -0,0 +1,7 @@
import sys
from typing import Iterable, Callable, Awaitable, Optional, Tuple, Any, List
from . import events
if sys.version_info >= (3, 8):
async def staggered_race(coro_fns: Iterable[Callable[[], Awaitable]], delay: Optional[float], *, loop: Optional[events.AbstractEventLoop] = ...) -> Tuple[Any, Optional[int], List[Optional[Exception]]]: ...

View File

@@ -0,0 +1,78 @@
import sys
import socket
from typing import Union, NoReturn, Tuple, Optional, Iterable, List, Any, BinaryIO, Type, overload
from types import TracebackType
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, offset: int = ..., count: Optional[int] = ...) -> int: ...
def close(self) -> None: ...
def detach(self) -> int: ...
if sys.platform == "linux":
def sendmsg_afalg(self, msg=..., *, op, iv=..., assoclen=..., flags=...) -> int: ...
else:
def sendmsg_afalg(self, msg=..., *, op, iv=..., assoclen=..., flags=...) -> 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: ...

View File

@@ -4,16 +4,21 @@ asyncio.Future._loop
asyncio.Future._tb_logger
asyncio.Task.__init__
asyncio.Task._wakeup
asyncio.base_futures # Added in Python 3.6
asyncio.base_tasks # Added in Python 3.6
asyncio.exceptions # Added in Python 3.8
asyncio.format_helpers # Added in Python 3.7
asyncio.futures.Future._callbacks
asyncio.futures.Future._exception
asyncio.futures.Future._loop
asyncio.futures.Future._tb_logger
asyncio.futures._TracebackLogger.__init__
asyncio.runners
asyncio.staggered # Added in Python 3.8
asyncio.tasks.Task.__init__
asyncio.tasks.Task._wakeup
asyncio.threads # Added in Python 3.9
asyncio.trsock # Added in Python 3.8
bdb.GENERATOR_AND_COROUTINE_FLAGS
builtins.str.maketrans
cmath.log

View File

@@ -1,9 +1,12 @@
asyncio.Future.__init__
asyncio.exceptions # Added in Python 3.8
asyncio.format_helpers # Added in Python 3.7
asyncio.futures.Future.__init__
asyncio.futures._TracebackLogger.__init__
asyncio.runners
asyncio.staggered # Added in Python 3.8
asyncio.threads # Added in Python 3.9
asyncio.trsock # Added in Python 3.8
builtins.str.maketrans
cmath.log
codecs.StreamRecoder.seek

View File

@@ -1,4 +1,5 @@
asyncio.AbstractEventLoop.sock_sendfile
asyncio.compat # Removed in 3.7
asyncio.Future.__init__
asyncio.Future._callbacks
asyncio.Handle.__init__
@@ -9,7 +10,9 @@ asyncio.events.TimerHandle.__init__
asyncio.exceptions # Added in Python 3.8
asyncio.futures.Future.__init__
asyncio.futures.Future._callbacks
asyncio.staggered # Added in Python 3.8
asyncio.threads # Added in Python 3.9
asyncio.trsock # Added in Python 3.8
builtins.dict.get
builtins.reversed
builtins.str.maketrans
@@ -38,7 +41,7 @@ importlib.metadata
ipaddress._BaseNetwork.__init__
json.loads
logging.handlers.MemoryHandler.__init__
macurl2path
macurl2path # removed in 3.7
multiprocessing.shared_memory
nntplib._NNTPBase.starttls
os.utime

View File

@@ -6,6 +6,7 @@ ast.NameConstant.__new__
ast.Num.__new__
ast.Str.__new__
asyncio.AbstractEventLoop.sock_sendfile
asyncio.compat # removed in 3.7
asyncio.Future.__init__
asyncio.Future._callbacks
asyncio.Handle.__init__
@@ -61,7 +62,7 @@ ipaddress._BaseNetwork.broadcast_address
ipaddress._BaseNetwork.hostmask
logging.handlers.MemoryHandler.__init__
macpath
macurl2path
macurl2path # removed in 3.7
mmap.MADV_[A-Z_]+
multiprocessing.managers.SharedMemoryServer.__init__
multiprocessing.pool.CLOSE

View File

@@ -14,6 +14,7 @@ ast.NameConstant.__new__
ast.Num.__new__
ast.Str.__new__
asyncio.AbstractEventLoop.sock_sendfile
asyncio.compat # removed in 3.7
asyncio.Future.__init__
asyncio.Future._callbacks
asyncio.Handle.__init__
@@ -121,7 +122,7 @@ logging.handlers.WatchedFileHandler.__init__
lzma.LZMACompressor.compress
lzma.is_check_supported
macpath
macurl2path
macurl2path # removed in 3.7
mmap.MADV_AUTOSYNC
mmap.MADV_CORE
mmap.MADV_NOCORE