stdlib: add argument default values (#9501)

This commit is contained in:
Jelle Zijlstra
2023-01-18 00:37:34 -08:00
committed by GitHub
parent 6cb934291f
commit ddfaca3200
272 changed files with 2529 additions and 2467 deletions

View File

@@ -34,7 +34,7 @@ class Server(AbstractServer):
ssl_context: _SSLContext,
backlog: int,
ssl_handshake_timeout: float | None,
ssl_shutdown_timeout: float | None = ...,
ssl_shutdown_timeout: float | None = None,
) -> None: ...
else:
def __init__(
@@ -74,18 +74,20 @@ class BaseEventLoop(AbstractEventLoop):
def close(self) -> None: ...
async def shutdown_asyncgens(self) -> None: ...
# Methods scheduling callbacks. All these return Handles.
def call_soon(self, callback: Callable[..., object], *args: Any, context: Context | None = ...) -> Handle: ...
def call_soon(self, callback: Callable[..., object], *args: Any, context: Context | None = None) -> Handle: ...
def call_later(
self, delay: float, callback: Callable[..., object], *args: Any, context: Context | None = ...
self, delay: float, callback: Callable[..., object], *args: Any, context: Context | None = None
) -> TimerHandle: ...
def call_at(
self, when: float, callback: Callable[..., object], *args: Any, context: Context | None = None
) -> TimerHandle: ...
def call_at(self, when: float, callback: Callable[..., object], *args: Any, context: Context | None = ...) -> TimerHandle: ...
def time(self) -> float: ...
# Future methods
def create_future(self) -> Future[Any]: ...
# Tasks methods
if sys.version_info >= (3, 11):
def create_task(
self, coro: Coroutine[Any, Any, _T] | Generator[Any, None, _T], *, name: object = ..., context: Context | None = ...
self, coro: Coroutine[Any, Any, _T] | Generator[Any, None, _T], *, name: object = None, context: Context | None = None
) -> Task[_T]: ...
elif sys.version_info >= (3, 8):
def create_task(self, coro: Coroutine[Any, Any, _T] | Generator[Any, None, _T], *, name: object = ...) -> Task[_T]: ...
@@ -95,7 +97,7 @@ class BaseEventLoop(AbstractEventLoop):
def set_task_factory(self, factory: _TaskFactory | None) -> None: ...
def get_task_factory(self) -> _TaskFactory | None: ...
# Methods for interacting with threads
def call_soon_threadsafe(self, callback: Callable[..., object], *args: Any, context: Context | None = ...) -> Handle: ...
def call_soon_threadsafe(self, callback: Callable[..., object], *args: Any, context: Context | None = None) -> 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.
@@ -104,12 +106,12 @@ class BaseEventLoop(AbstractEventLoop):
host: bytes | str | None,
port: bytes | str | int | None,
*,
family: int = ...,
type: int = ...,
proto: int = ...,
flags: int = ...,
family: int = 0,
type: int = 0,
proto: int = 0,
flags: int = 0,
) -> list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int]]]: ...
async def getnameinfo(self, sockaddr: tuple[str, int] | tuple[str, int, int, int], flags: int = ...) -> tuple[str, str]: ...
async def getnameinfo(self, sockaddr: tuple[str, int] | tuple[str, int, int, int], flags: int = 0) -> tuple[str, str]: ...
if sys.version_info >= (3, 11):
@overload
async def create_connection(
@@ -262,19 +264,19 @@ class BaseEventLoop(AbstractEventLoop):
protocol: BaseProtocol,
sslcontext: ssl.SSLContext,
*,
server_side: bool = ...,
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
ssl_shutdown_timeout: float | None = ...,
server_side: bool = False,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
) -> Transport: ...
async def connect_accepted_socket(
self,
protocol_factory: Callable[[], _ProtocolT],
sock: socket,
*,
ssl: _SSLContext = ...,
ssl_handshake_timeout: float | None = ...,
ssl_shutdown_timeout: float | None = ...,
ssl: _SSLContext = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
) -> tuple[Transport, _ProtocolT]: ...
else:
@overload
@@ -331,24 +333,24 @@ class BaseEventLoop(AbstractEventLoop):
) -> tuple[Transport, _ProtocolT]: ...
async def sock_sendfile(
self, sock: socket, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool | None = ...
self, sock: socket, file: IO[bytes], offset: int = 0, count: int | None = None, *, fallback: bool | None = True
) -> int: ...
async def sendfile(
self, transport: WriteTransport, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool = ...
self, transport: WriteTransport, file: IO[bytes], offset: int = 0, count: int | None = None, *, fallback: bool = True
) -> int: ...
if sys.version_info >= (3, 11):
async def create_datagram_endpoint( # type: ignore[override]
self,
protocol_factory: Callable[[], _ProtocolT],
local_addr: tuple[str, int] | None = ...,
remote_addr: tuple[str, int] | None = ...,
local_addr: tuple[str, int] | None = None,
remote_addr: tuple[str, int] | None = None,
*,
family: int = ...,
proto: int = ...,
flags: int = ...,
reuse_port: bool | None = ...,
allow_broadcast: bool | None = ...,
sock: socket | None = ...,
family: int = 0,
proto: int = 0,
flags: int = 0,
reuse_port: bool | None = None,
allow_broadcast: bool | None = None,
sock: socket | None = None,
) -> tuple[DatagramTransport, _ProtocolT]: ...
else:
async def create_datagram_endpoint(
@@ -377,15 +379,15 @@ class BaseEventLoop(AbstractEventLoop):
protocol_factory: Callable[[], _ProtocolT],
cmd: bytes | str,
*,
stdin: int | IO[Any] | None = ...,
stdout: int | IO[Any] | None = ...,
stderr: int | IO[Any] | None = ...,
universal_newlines: Literal[False] = ...,
shell: Literal[True] = ...,
bufsize: Literal[0] = ...,
encoding: None = ...,
errors: None = ...,
text: Literal[False, None] = ...,
stdin: int | IO[Any] | None = -1,
stdout: int | IO[Any] | None = -1,
stderr: int | IO[Any] | None = -1,
universal_newlines: Literal[False] = False,
shell: Literal[True] = True,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
text: Literal[False, None] = None,
**kwargs: Any,
) -> tuple[SubprocessTransport, _ProtocolT]: ...
async def subprocess_exec(
@@ -393,14 +395,14 @@ class BaseEventLoop(AbstractEventLoop):
protocol_factory: Callable[[], _ProtocolT],
program: Any,
*args: Any,
stdin: int | IO[Any] | None = ...,
stdout: int | IO[Any] | None = ...,
stderr: int | IO[Any] | None = ...,
universal_newlines: Literal[False] = ...,
stdin: int | IO[Any] | None = -1,
stdout: int | IO[Any] | None = -1,
stderr: int | IO[Any] | None = -1,
universal_newlines: Literal[False] = False,
shell: Literal[True] = ...,
bufsize: Literal[0] = ...,
encoding: None = ...,
errors: None = ...,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
**kwargs: Any,
) -> tuple[SubprocessTransport, _ProtocolT]: ...
def add_reader(self, fd: FileDescriptorLike, callback: Callable[..., Any], *args: Any) -> None: ...
@@ -416,7 +418,7 @@ class BaseEventLoop(AbstractEventLoop):
async def sock_accept(self, sock: socket) -> tuple[socket, _RetAddress]: ...
if sys.version_info >= (3, 11):
async def sock_recvfrom(self, sock: socket, bufsize: int) -> bytes: ...
async def sock_recvfrom_into(self, sock: socket, buf: WriteableBuffer, nbytes: int = ...) -> int: ...
async def sock_recvfrom_into(self, sock: socket, buf: WriteableBuffer, nbytes: int = 0) -> int: ...
async def sock_sendto(self, sock: socket, data: ReadableBuffer, address: _Address) -> None: ...
# Signal handling.
def add_signal_handler(self, sig: int, callback: Callable[..., Any], *args: Any) -> None: ...

View File

@@ -30,8 +30,8 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
stdout: _File,
stderr: _File,
bufsize: int,
waiter: futures.Future[Any] | None = ...,
extra: Any | None = ...,
waiter: futures.Future[Any] | None = None,
extra: Any | None = None,
**kwargs: Any,
) -> None: ...
def _start(

View File

@@ -70,7 +70,7 @@ class Handle:
_cancelled: bool
_args: Sequence[Any]
def __init__(
self, callback: Callable[..., object], args: Sequence[Any], loop: AbstractEventLoop, context: Context | None = ...
self, callback: Callable[..., object], args: Sequence[Any], loop: AbstractEventLoop, context: Context | None = None
) -> None: ...
def cancel(self) -> None: ...
def _run(self) -> None: ...
@@ -83,7 +83,7 @@ class TimerHandle(Handle):
callback: Callable[..., object],
args: Sequence[Any],
loop: AbstractEventLoop,
context: Context | None = ...,
context: Context | None = None,
) -> None: ...
def when(self) -> float: ...
def __lt__(self, other: TimerHandle) -> bool: ...
@@ -132,14 +132,14 @@ class AbstractEventLoop:
# Methods scheduling callbacks. All these return Handles.
if sys.version_info >= (3, 9): # "context" added in 3.9.10/3.10.2
@abstractmethod
def call_soon(self, callback: Callable[..., object], *args: Any, context: Context | None = ...) -> Handle: ...
def call_soon(self, callback: Callable[..., object], *args: Any, context: Context | None = None) -> Handle: ...
@abstractmethod
def call_later(
self, delay: float, callback: Callable[..., object], *args: Any, context: Context | None = ...
self, delay: float, callback: Callable[..., object], *args: Any, context: Context | None = None
) -> TimerHandle: ...
@abstractmethod
def call_at(
self, when: float, callback: Callable[..., object], *args: Any, context: Context | None = ...
self, when: float, callback: Callable[..., object], *args: Any, context: Context | None = None
) -> TimerHandle: ...
else:
@abstractmethod
@@ -161,8 +161,8 @@ class AbstractEventLoop:
self,
coro: Coroutine[Any, Any, _T] | Generator[Any, None, _T],
*,
name: str | None = ...,
context: Context | None = ...,
name: str | None = None,
context: Context | None = None,
) -> Task[_T]: ...
elif sys.version_info >= (3, 8):
@abstractmethod
@@ -180,7 +180,7 @@ class AbstractEventLoop:
# Methods for interacting with threads
if sys.version_info >= (3, 9): # "context" added in 3.9.10/3.10.2
@abstractmethod
def call_soon_threadsafe(self, callback: Callable[..., object], *args: Any, context: Context | None = ...) -> Handle: ...
def call_soon_threadsafe(self, callback: Callable[..., object], *args: Any, context: Context | None = None) -> Handle: ...
else:
@abstractmethod
def call_soon_threadsafe(self, callback: Callable[..., object], *args: Any) -> Handle: ...
@@ -196,13 +196,13 @@ class AbstractEventLoop:
host: bytes | str | None,
port: bytes | str | int | None,
*,
family: int = ...,
type: int = ...,
proto: int = ...,
flags: int = ...,
family: int = 0,
type: int = 0,
proto: int = 0,
flags: int = 0,
) -> list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int]]]: ...
@abstractmethod
async def getnameinfo(self, sockaddr: tuple[str, int] | tuple[str, int, int, int], flags: int = ...) -> tuple[str, str]: ...
async def getnameinfo(self, sockaddr: tuple[str, int] | tuple[str, int, int, int], flags: int = 0) -> tuple[str, str]: ...
if sys.version_info >= (3, 11):
@overload
@abstractmethod
@@ -364,22 +364,22 @@ class AbstractEventLoop:
protocol: BaseProtocol,
sslcontext: ssl.SSLContext,
*,
server_side: bool = ...,
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
ssl_shutdown_timeout: float | None = ...,
server_side: bool = False,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
) -> Transport: ...
async def create_unix_server(
self,
protocol_factory: _ProtocolFactory,
path: StrPath | None = ...,
path: StrPath | None = None,
*,
sock: socket | None = ...,
backlog: int = ...,
ssl: _SSLContext = ...,
ssl_handshake_timeout: float | None = ...,
ssl_shutdown_timeout: float | None = ...,
start_serving: bool = ...,
sock: socket | None = None,
backlog: int = 100,
ssl: _SSLContext = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
else:
@overload
@@ -446,9 +446,9 @@ class AbstractEventLoop:
protocol_factory: Callable[[], _ProtocolT],
sock: socket,
*,
ssl: _SSLContext = ...,
ssl_handshake_timeout: float | None = ...,
ssl_shutdown_timeout: float | None = ...,
ssl: _SSLContext = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
) -> tuple[Transport, _ProtocolT]: ...
elif sys.version_info >= (3, 10):
async def connect_accepted_socket(
@@ -463,13 +463,13 @@ class AbstractEventLoop:
async def create_unix_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
path: str | None = ...,
path: str | None = None,
*,
ssl: _SSLContext = ...,
sock: socket | None = ...,
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
ssl_shutdown_timeout: float | None = ...,
ssl: _SSLContext = None,
sock: socket | None = None,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
) -> tuple[Transport, _ProtocolT]: ...
else:
async def create_unix_connection(
@@ -485,26 +485,26 @@ class AbstractEventLoop:
@abstractmethod
async def sock_sendfile(
self, sock: socket, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool | None = ...
self, sock: socket, file: IO[bytes], offset: int = 0, count: int | None = None, *, fallback: bool | None = None
) -> int: ...
@abstractmethod
async def sendfile(
self, transport: WriteTransport, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool = ...
self, transport: WriteTransport, file: IO[bytes], offset: int = 0, count: int | None = None, *, fallback: bool = True
) -> int: ...
@abstractmethod
async def create_datagram_endpoint(
self,
protocol_factory: Callable[[], _ProtocolT],
local_addr: tuple[str, int] | None = ...,
remote_addr: tuple[str, int] | None = ...,
local_addr: tuple[str, int] | None = None,
remote_addr: tuple[str, int] | None = None,
*,
family: int = ...,
proto: int = ...,
flags: int = ...,
reuse_address: bool | None = ...,
reuse_port: bool | None = ...,
allow_broadcast: bool | None = ...,
sock: socket | None = ...,
family: int = 0,
proto: int = 0,
flags: int = 0,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
allow_broadcast: bool | None = None,
sock: socket | None = None,
) -> tuple[DatagramTransport, _ProtocolT]: ...
# Pipes and subprocesses.
@abstractmethod
@@ -521,9 +521,9 @@ class AbstractEventLoop:
protocol_factory: Callable[[], _ProtocolT],
cmd: bytes | str,
*,
stdin: int | IO[Any] | None = ...,
stdout: int | IO[Any] | None = ...,
stderr: int | IO[Any] | None = ...,
stdin: int | IO[Any] | None = -1,
stdout: int | IO[Any] | None = -1,
stderr: int | IO[Any] | None = -1,
universal_newlines: Literal[False] = ...,
shell: Literal[True] = ...,
bufsize: Literal[0] = ...,
@@ -538,9 +538,9 @@ class AbstractEventLoop:
protocol_factory: Callable[[], _ProtocolT],
program: Any,
*args: Any,
stdin: int | IO[Any] | None = ...,
stdout: int | IO[Any] | None = ...,
stderr: int | IO[Any] | None = ...,
stdin: int | IO[Any] | None = -1,
stdout: int | IO[Any] | None = -1,
stderr: int | IO[Any] | None = -1,
universal_newlines: Literal[False] = ...,
shell: Literal[True] = ...,
bufsize: Literal[0] = ...,
@@ -571,7 +571,7 @@ class AbstractEventLoop:
@abstractmethod
async def sock_recvfrom(self, sock: socket, bufsize: int) -> bytes: ...
@abstractmethod
async def sock_recvfrom_into(self, sock: socket, buf: WriteableBuffer, nbytes: int = ...) -> int: ...
async def sock_recvfrom_into(self, sock: socket, buf: WriteableBuffer, nbytes: int = 0) -> int: ...
@abstractmethod
async def sock_sendto(self, sock: socket, data: ReadableBuffer, address: _Address) -> None: ...
# Signal handling.

View File

@@ -16,5 +16,5 @@ def _get_function_source(func: _FuncType) -> tuple[str, int]: ...
def _get_function_source(func: object) -> tuple[str, int] | None: ...
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: FrameType | None = ..., limit: int | None = ...) -> traceback.StackSummary: ...
def _format_callback(func: object, args: Iterable[Any], kwargs: dict[str, Any], suffix: str = "") -> str: ...
def extract_stack(f: FrameType | None = None, limit: int | None = None) -> traceback.StackSummary: ...

View File

@@ -46,7 +46,7 @@ class Future(Awaitable[_T], Iterable[_T]):
def _callbacks(self: Self) -> list[tuple[Callable[[Self], Any], Context]]: ...
def add_done_callback(self: Self, __fn: Callable[[Self], object], *, context: Context | None = ...) -> None: ...
if sys.version_info >= (3, 9):
def cancel(self, msg: Any | None = ...) -> bool: ...
def cancel(self, msg: Any | None = None) -> bool: ...
else:
def cancel(self) -> bool: ...
@@ -64,4 +64,4 @@ class Future(Awaitable[_T], Iterable[_T]):
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
def wrap_future(future: _ConcurrentFuture[_T] | Future[_T], *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ...
def wrap_future(future: _ConcurrentFuture[_T] | Future[_T], *, loop: AbstractEventLoop | None = None) -> Future[_T]: ...

View File

@@ -67,7 +67,7 @@ class Event:
class Condition(_ContextManagerMixin):
if sys.version_info >= (3, 11):
def __init__(self, lock: Lock | None = ...) -> None: ...
def __init__(self, lock: Lock | None = None) -> None: ...
else:
def __init__(self, lock: Lock | None = ..., *, loop: AbstractEventLoop | None = ...) -> None: ...
@@ -76,14 +76,14 @@ class Condition(_ContextManagerMixin):
def release(self) -> None: ...
async def wait(self) -> Literal[True]: ...
async def wait_for(self, predicate: Callable[[], _T]) -> _T: ...
def notify(self, n: int = ...) -> None: ...
def notify(self, n: int = 1) -> None: ...
def notify_all(self) -> None: ...
class Semaphore(_ContextManagerMixin):
_value: int
_waiters: deque[Future[Any]]
if sys.version_info >= (3, 11):
def __init__(self, value: int = ...) -> None: ...
def __init__(self, value: int = 1) -> None: ...
else:
def __init__(self, value: int = ..., *, loop: AbstractEventLoop | None = ...) -> None: ...

View File

@@ -20,9 +20,9 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTr
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: futures.Future[Any] | None = ...,
extra: Mapping[Any, Any] | None = ...,
server: events.AbstractServer | None = ...,
waiter: futures.Future[Any] | None = None,
extra: Mapping[Any, Any] | None = None,
server: events.AbstractServer | None = None,
) -> None: ...
if sys.version_info >= (3, 8):
def __del__(self, _warn: _WarnCallbackProtocol = ...) -> None: ...
@@ -36,10 +36,10 @@ class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTran
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: futures.Future[Any] | None = ...,
extra: Mapping[Any, Any] | None = ...,
server: events.AbstractServer | None = ...,
buffer_size: int = ...,
waiter: futures.Future[Any] | None = None,
extra: Mapping[Any, Any] | None = None,
server: events.AbstractServer | None = None,
buffer_size: int = 65536,
) -> None: ...
else:
def __init__(
@@ -64,9 +64,9 @@ class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePip
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: futures.Future[Any] | None = ...,
extra: Mapping[Any, Any] | None = ...,
server: events.AbstractServer | None = ...,
waiter: futures.Future[Any] | None = None,
extra: Mapping[Any, Any] | None = None,
server: events.AbstractServer | None = None,
) -> None: ...
def _set_extra(self, sock: socket) -> None: ...
def can_write_eof(self) -> Literal[True]: ...

View File

@@ -14,7 +14,7 @@ _T = TypeVar("_T")
class Queue(Generic[_T]):
if sys.version_info >= (3, 11):
def __init__(self, maxsize: int = ...) -> None: ...
def __init__(self, maxsize: int = 0) -> None: ...
else:
def __init__(self, maxsize: int = ..., *, loop: AbstractEventLoop | None = ...) -> None: ...

View File

@@ -16,12 +16,12 @@ _T = TypeVar("_T")
if sys.version_info >= (3, 11):
@final
class Runner:
def __init__(self, *, debug: bool | None = ..., loop_factory: Callable[[], AbstractEventLoop] | None = ...) -> None: ...
def __init__(self, *, debug: bool | None = None, loop_factory: Callable[[], AbstractEventLoop] | None = None) -> None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(self, exc_type: Unused, exc_val: Unused, exc_tb: Unused) -> None: ...
def close(self) -> None: ...
def get_loop(self) -> AbstractEventLoop: ...
def run(self, coro: Coroutine[Any, Any, _T], *, context: Context | None = ...) -> _T: ...
def run(self, coro: Coroutine[Any, Any, _T], *, context: Context | None = None) -> _T: ...
if sys.version_info >= (3, 12):
def run(
@@ -29,7 +29,7 @@ if sys.version_info >= (3, 12):
) -> _T: ...
elif sys.version_info >= (3, 8):
def run(main: Coroutine[Any, Any, _T], *, debug: bool | None = ...) -> _T: ...
def run(main: Coroutine[Any, Any, _T], *, debug: bool | None = None) -> _T: ...
else:
def run(main: Coroutine[Any, Any, _T], *, debug: bool = ...) -> _T: ...

View File

@@ -5,4 +5,4 @@ from . import base_events
__all__ = ("BaseSelectorEventLoop",)
class BaseSelectorEventLoop(base_events.BaseEventLoop):
def __init__(self, selector: selectors.BaseSelector | None = ...) -> None: ...
def __init__(self, selector: selectors.BaseSelector | None = None) -> None: ...

View File

@@ -71,7 +71,7 @@ class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport):
_ssl_protocol: SSLProtocol
_closed: bool
def __init__(self, loop: events.AbstractEventLoop, ssl_protocol: SSLProtocol) -> None: ...
def get_extra_info(self, name: str, default: Any | None = ...) -> dict[str, Any]: ...
def get_extra_info(self, name: str, default: Any | None = None) -> dict[str, Any]: ...
@property
def _protocol_paused(self) -> bool: ...
def write(self, data: bytes | bytearray | memoryview) -> None: ...
@@ -79,7 +79,7 @@ class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport):
if sys.version_info >= (3, 11):
def get_write_buffer_limits(self) -> tuple[int, int]: ...
def get_read_buffer_limits(self) -> tuple[int, int]: ...
def set_read_buffer_limits(self, high: int | None = ..., low: int | None = ...) -> None: ...
def set_read_buffer_limits(self, high: int | None = None, low: int | None = None) -> None: ...
def get_read_buffer_size(self) -> int: ...
if sys.version_info >= (3, 11):
@@ -118,11 +118,11 @@ class SSLProtocol(_SSLProtocolBase):
app_protocol: protocols.BaseProtocol,
sslcontext: ssl.SSLContext,
waiter: futures.Future[Any],
server_side: bool = ...,
server_hostname: str | None = ...,
call_connection_made: bool = ...,
ssl_handshake_timeout: int | None = ...,
ssl_shutdown_timeout: float | None = ...,
server_side: bool = False,
server_hostname: str | None = None,
call_connection_made: bool = True,
ssl_handshake_timeout: int | None = None,
ssl_shutdown_timeout: float | None = None,
) -> None: ...
else:
def __init__(
@@ -138,10 +138,10 @@ class SSLProtocol(_SSLProtocolBase):
) -> None: ...
def _set_app_protocol(self, app_protocol: protocols.BaseProtocol) -> None: ...
def _wakeup_waiter(self, exc: BaseException | None = ...) -> None: ...
def _wakeup_waiter(self, exc: BaseException | None = None) -> None: ...
def connection_lost(self, exc: BaseException | None) -> None: ...
def eof_received(self) -> None: ...
def _get_extra_info(self, name: str, default: Any | None = ...) -> Any: ...
def _get_extra_info(self, name: str, default: Any | None = None) -> Any: ...
def _start_shutdown(self) -> None: ...
if sys.version_info >= (3, 11):
def _write_appdata(self, list_of_data: list[bytes]) -> None: ...
@@ -151,7 +151,7 @@ class SSLProtocol(_SSLProtocolBase):
def _start_handshake(self) -> None: ...
def _check_handshake_timeout(self) -> None: ...
def _on_handshake_complete(self, handshake_exc: BaseException | None) -> None: ...
def _fatal_error(self, exc: BaseException, message: str = ...) -> None: ...
def _fatal_error(self, exc: BaseException, message: str = "Fatal error on transport") -> None: ...
def _abort(self) -> None: ...
if sys.version_info >= (3, 11):
def get_buffer(self, n: int) -> memoryview: ...

View File

@@ -6,5 +6,5 @@ from . import events
__all__ = ("staggered_race",)
async def staggered_race(
coro_fns: Iterable[Callable[[], Awaitable[Any]]], delay: float | None, *, loop: events.AbstractEventLoop | None = ...
coro_fns: Iterable[Callable[[], Awaitable[Any]]], delay: float | None, *, loop: events.AbstractEventLoop | None = None
) -> tuple[Any, int | None, list[Exception | None]]: ...

View File

@@ -59,19 +59,19 @@ if sys.version_info < (3, 8):
if sys.version_info >= (3, 10):
async def open_connection(
host: str | None = ...,
port: int | str | None = ...,
host: str | None = None,
port: int | str | None = None,
*,
limit: int = ...,
limit: int = 65536,
ssl_handshake_timeout: float | None = ...,
**kwds: Any,
) -> tuple[StreamReader, StreamWriter]: ...
async def start_server(
client_connected_cb: _ClientConnectedCallback,
host: str | Sequence[str] | None = ...,
port: int | str | None = ...,
host: str | Sequence[str] | None = None,
port: int | str | None = None,
*,
limit: int = ...,
limit: int = 65536,
ssl_handshake_timeout: float | None = ...,
**kwds: Any,
) -> Server: ...
@@ -100,10 +100,10 @@ else:
if sys.platform != "win32":
if sys.version_info >= (3, 10):
async def open_unix_connection(
path: StrPath | None = ..., *, limit: int = ..., **kwds: Any
path: StrPath | None = None, *, limit: int = 65536, **kwds: Any
) -> tuple[StreamReader, StreamWriter]: ...
async def start_unix_server(
client_connected_cb: _ClientConnectedCallback, path: StrPath | None = ..., *, limit: int = ..., **kwds: Any
client_connected_cb: _ClientConnectedCallback, path: StrPath | None = None, *, limit: int = 65536, **kwds: Any
) -> Server: ...
else:
async def open_unix_connection(
@@ -119,14 +119,14 @@ if sys.platform != "win32":
) -> Server: ...
class FlowControlMixin(protocols.Protocol):
def __init__(self, loop: events.AbstractEventLoop | None = ...) -> None: ...
def __init__(self, loop: events.AbstractEventLoop | None = None) -> None: ...
class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
def __init__(
self,
stream_reader: StreamReader,
client_connected_cb: _ClientConnectedCallback | None = ...,
loop: events.AbstractEventLoop | None = ...,
client_connected_cb: _ClientConnectedCallback | None = None,
loop: events.AbstractEventLoop | None = None,
) -> None: ...
class StreamWriter:
@@ -146,15 +146,15 @@ class StreamWriter:
def close(self) -> None: ...
def is_closing(self) -> bool: ...
async def wait_closed(self) -> None: ...
def get_extra_info(self, name: str, default: Any = ...) -> Any: ...
def get_extra_info(self, name: str, default: Any = None) -> Any: ...
async def drain(self) -> None: ...
if sys.version_info >= (3, 11):
async def start_tls(
self, sslcontext: ssl.SSLContext, *, server_hostname: str | None = ..., ssl_handshake_timeout: float | None = ...
self, sslcontext: ssl.SSLContext, *, server_hostname: str | None = None, ssl_handshake_timeout: float | None = None
) -> None: ...
class StreamReader(AsyncIterator[bytes]):
def __init__(self, limit: int = ..., loop: events.AbstractEventLoop | None = ...) -> None: ...
def __init__(self, limit: int = 65536, loop: events.AbstractEventLoop | None = None) -> None: ...
def exception(self) -> Exception: ...
def set_exception(self, exc: Exception) -> None: ...
def set_transport(self, transport: transports.BaseTransport) -> None: ...
@@ -164,7 +164,7 @@ class StreamReader(AsyncIterator[bytes]):
async def readline(self) -> bytes: ...
# Can be any buffer that supports len(); consider changing to a Protocol if PEP 688 is accepted
async def readuntil(self, separator: bytes | bytearray | memoryview = ...) -> bytes: ...
async def read(self, n: int = ...) -> bytes: ...
async def read(self, n: int = -1) -> bytes: ...
async def readexactly(self, n: int) -> bytes: ...
def __aiter__(self: Self) -> Self: ...
async def __anext__(self) -> bytes: ...

View File

@@ -38,15 +38,15 @@ class Process:
def send_signal(self, signal: int) -> None: ...
def terminate(self) -> None: ...
def kill(self) -> None: ...
async def communicate(self, input: bytes | bytearray | memoryview | None = ...) -> tuple[bytes, bytes]: ...
async def communicate(self, input: bytes | bytearray | memoryview | None = None) -> tuple[bytes, bytes]: ...
if sys.version_info >= (3, 11):
async def create_subprocess_shell(
cmd: str | bytes,
stdin: int | IO[Any] | None = ...,
stdout: int | IO[Any] | None = ...,
stderr: int | IO[Any] | None = ...,
limit: int = ...,
stdin: int | IO[Any] | None = None,
stdout: int | IO[Any] | None = None,
stderr: int | IO[Any] | None = None,
limit: int = 65536,
*,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
universal_newlines: Literal[False] = ...,
@@ -76,10 +76,10 @@ if sys.version_info >= (3, 11):
async def create_subprocess_exec(
program: _ExecArg,
*args: _ExecArg,
stdin: int | IO[Any] | None = ...,
stdout: int | IO[Any] | None = ...,
stderr: int | IO[Any] | None = ...,
limit: int = ...,
stdin: int | IO[Any] | None = None,
stdout: int | IO[Any] | None = None,
stderr: int | IO[Any] | None = None,
limit: int = 65536,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
universal_newlines: Literal[False] = ...,
shell: Literal[True] = ...,

View File

@@ -16,5 +16,5 @@ class TaskGroup:
async def __aenter__(self: Self) -> Self: ...
async def __aexit__(self, et: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) -> None: ...
def create_task(
self, coro: Generator[Any, None, _T] | Coroutine[Any, Any, _T], *, name: str | None = ..., context: Context | None = ...
self, coro: Generator[Any, None, _T] | Coroutine[Any, Any, _T], *, name: str | None = None, context: Context | None = None
) -> Task[_T]: ...

View File

@@ -51,7 +51,7 @@ FIRST_EXCEPTION = concurrent.futures.FIRST_EXCEPTION
ALL_COMPLETED = concurrent.futures.ALL_COMPLETED
if sys.version_info >= (3, 10):
def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = ...) -> Iterator[Future[_T]]: ...
def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> Iterator[Future[_T]]: ...
else:
def as_completed(
@@ -288,8 +288,8 @@ class Task(Future[_T_co], Generic[_T_co]): # type: ignore[type-var] # pyright:
def get_name(self) -> str: ...
def set_name(self, __value: object) -> None: ...
def get_stack(self, *, limit: int | None = ...) -> list[FrameType]: ...
def print_stack(self, *, limit: int | None = ..., file: TextIO | None = ...) -> None: ...
def get_stack(self, *, limit: int | None = None) -> list[FrameType]: ...
def print_stack(self, *, limit: int | None = None, file: TextIO | None = None) -> None: ...
if sys.version_info >= (3, 11):
def cancelling(self) -> int: ...
def uncancel(self) -> int: ...
@@ -301,11 +301,11 @@ class Task(Future[_T_co], Generic[_T_co]): # type: ignore[type-var] # pyright:
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
def all_tasks(loop: AbstractEventLoop | None = ...) -> set[Task[Any]]: ...
def all_tasks(loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ...
if sys.version_info >= (3, 11):
def create_task(
coro: Generator[Any, None, _T] | Coroutine[Any, Any, _T], *, name: str | None = ..., context: Context | None = ...
coro: Generator[Any, None, _T] | Coroutine[Any, Any, _T], *, name: str | None = None, context: Context | None = None
) -> Task[_T]: ...
elif sys.version_info >= (3, 8):
@@ -314,7 +314,7 @@ elif sys.version_info >= (3, 8):
else:
def create_task(coro: Generator[Any, None, _T] | Coroutine[Any, Any, _T]) -> Task[_T]: ...
def current_task(loop: AbstractEventLoop | None = ...) -> Task[Any] | None: ...
def current_task(loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
def _enter_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ...
def _leave_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ...
def _register_task(task: Task[Any]) -> None: ...

View File

@@ -7,8 +7,8 @@ from typing import Any
__all__ = ("BaseTransport", "ReadTransport", "WriteTransport", "Transport", "DatagramTransport", "SubprocessTransport")
class BaseTransport:
def __init__(self, extra: Mapping[str, Any] | None = ...) -> None: ...
def get_extra_info(self, name: str, default: Any = ...) -> Any: ...
def __init__(self, extra: Mapping[str, Any] | None = None) -> None: ...
def get_extra_info(self, name: str, default: Any = None) -> Any: ...
def is_closing(self) -> bool: ...
def close(self) -> None: ...
def set_protocol(self, protocol: BaseProtocol) -> None: ...
@@ -20,7 +20,7 @@ class ReadTransport(BaseTransport):
def resume_reading(self) -> None: ...
class WriteTransport(BaseTransport):
def set_write_buffer_limits(self, high: int | None = ..., low: int | None = ...) -> None: ...
def set_write_buffer_limits(self, high: int | None = None, low: int | None = None) -> None: ...
def get_write_buffer_size(self) -> int: ...
def get_write_buffer_limits(self) -> tuple[int, int]: ...
def write(self, data: bytes | bytearray | memoryview) -> None: ...
@@ -32,7 +32,7 @@ class WriteTransport(BaseTransport):
class Transport(ReadTransport, WriteTransport): ...
class DatagramTransport(BaseTransport):
def sendto(self, data: bytes | bytearray | memoryview, addr: _Address | None = ...) -> None: ...
def sendto(self, data: bytes | bytearray | memoryview, addr: _Address | None = None) -> None: ...
def abort(self) -> None: ...
class SubprocessTransport(BaseTransport):
@@ -44,4 +44,4 @@ class SubprocessTransport(BaseTransport):
def kill(self) -> None: ...
class _FlowControlMixin(Transport):
def __init__(self, extra: Mapping[str, Any] | None = ..., loop: AbstractEventLoop | None = ...) -> None: ...
def __init__(self, extra: Mapping[str, Any] | None = None, loop: AbstractEventLoop | None = None) -> None: ...