Big diff: Use new "|" union syntax (#5872)

This commit is contained in:
Akuli
2021-08-08 12:05:21 +03:00
committed by GitHub
parent b9adb7a874
commit ee487304d7
578 changed files with 8080 additions and 8966 deletions

View File

@@ -9,7 +9,7 @@ from asyncio.tasks import Task
from asyncio.transports import BaseTransport
from collections.abc import Iterable
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 import IO, Any, Awaitable, Callable, Dict, Generator, List, Sequence, Tuple, TypeVar, Union, overload
from typing_extensions import Literal
if sys.version_info >= (3, 7):
@@ -31,7 +31,7 @@ class Server(AbstractServer):
protocol_factory: _ProtocolFactory,
ssl_context: _SSLContext,
backlog: int,
ssl_handshake_timeout: Optional[float],
ssl_handshake_timeout: float | None,
) -> None: ...
else:
def __init__(self, loop: AbstractEventLoop, sockets: list[socket]) -> None: ...
@@ -42,7 +42,7 @@ class Server(AbstractServer):
@property
def sockets(self) -> list[socket]: ...
else:
sockets: Optional[list[socket]]
sockets: list[socket] | None
class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
def run_forever(self) -> None: ...
@@ -58,12 +58,12 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
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_soon(self, callback: Callable[..., Any], *args: Any, context: Context | None = ...) -> Handle: ...
def call_later(
self, delay: float, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ...
self, delay: float, callback: Callable[..., Any], *args: Any, context: Context | None = ...
) -> TimerHandle: ...
def call_at(
self, when: float, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ...
self, when: float, callback: Callable[..., Any], *args: Any, context: Context | None = ...
) -> TimerHandle: ...
else:
def call_soon(self, callback: Callable[..., Any], *args: Any) -> Handle: ...
@@ -74,34 +74,23 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
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: object = ...) -> Task[_T]: ...
def create_task(self, coro: Awaitable[_T] | Generator[Any, None, _T], *, name: object = ...) -> 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]]]: ...
def create_task(self, coro: Awaitable[_T] | Generator[Any, None, _T]) -> Task[_T]: ...
def set_task_factory(self, factory: Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]] | None) -> None: ...
def get_task_factory(self) -> Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]] | None: ...
# 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: ...
def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any, context: Context | None = ...) -> 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]: ...
self, host: str | None, port: str | int | None, *, family: int = ..., type: int = ..., proto: int = ..., flags: int = ...
) -> 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]: ...
if sys.version_info >= (3, 8):
@overload
async def create_connection(
@@ -115,11 +104,11 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
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] = ...,
local_addr: Tuple[str, int] | None = ...,
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
happy_eyeballs_delay: float | None = ...,
interleave: int | None = ...,
) -> _TransProtPair: ...
@overload
async def create_connection(
@@ -134,10 +123,10 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
flags: int = ...,
sock: socket,
local_addr: None = ...,
server_hostname: Optional[str] = ...,
ssl_handshake_timeout: Optional[float] = ...,
happy_eyeballs_delay: Optional[float] = ...,
interleave: Optional[int] = ...,
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
happy_eyeballs_delay: float | None = ...,
interleave: int | None = ...,
) -> _TransProtPair: ...
elif sys.version_info >= (3, 7):
@overload
@@ -152,9 +141,9 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
proto: int = ...,
flags: int = ...,
sock: None = ...,
local_addr: Optional[Tuple[str, int]] = ...,
server_hostname: Optional[str] = ...,
ssl_handshake_timeout: Optional[float] = ...,
local_addr: Tuple[str, int] | None = ...,
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
) -> _TransProtPair: ...
@overload
async def create_connection(
@@ -169,8 +158,8 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
flags: int = ...,
sock: socket,
local_addr: None = ...,
server_hostname: Optional[str] = ...,
ssl_handshake_timeout: Optional[float] = ...,
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
) -> _TransProtPair: ...
else:
@overload
@@ -185,8 +174,8 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
proto: int = ...,
flags: int = ...,
sock: None = ...,
local_addr: Optional[Tuple[str, int]] = ...,
server_hostname: Optional[str] = ...,
local_addr: Tuple[str, int] | None = ...,
server_hostname: str | None = ...,
) -> _TransProtPair: ...
@overload
async def create_connection(
@@ -201,17 +190,17 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
flags: int = ...,
sock: socket,
local_addr: None = ...,
server_hostname: Optional[str] = ...,
server_hostname: str | None = ...,
) -> _TransProtPair: ...
if sys.version_info >= (3, 7):
async def sock_sendfile(
self, sock: socket, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *, fallback: Optional[bool] = ...
self, sock: socket, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool | None = ...
) -> int: ...
@overload
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: Optional[Union[str, Sequence[str]]] = ...,
host: str | Sequence[str] | None = ...,
port: int = ...,
*,
family: int = ...,
@@ -219,9 +208,9 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
sock: None = ...,
backlog: int = ...,
ssl: _SSLContext = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...,
ssl_handshake_timeout: Optional[float] = ...,
reuse_address: bool | None = ...,
reuse_port: bool | None = ...,
ssl_handshake_timeout: float | None = ...,
start_serving: bool = ...,
) -> Server: ...
@overload
@@ -236,9 +225,9 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
sock: socket = ...,
backlog: int = ...,
ssl: _SSLContext = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...,
ssl_handshake_timeout: Optional[float] = ...,
reuse_address: bool | None = ...,
reuse_port: bool | None = ...,
ssl_handshake_timeout: float | None = ...,
start_serving: bool = ...,
) -> Server: ...
async def connect_accepted_socket(
@@ -247,16 +236,10 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
sock: socket,
*,
ssl: _SSLContext = ...,
ssl_handshake_timeout: Optional[float] = ...,
ssl_handshake_timeout: float | None = ...,
) -> _TransProtPair: ...
async def sendfile(
self,
transport: BaseTransport,
file: IO[bytes],
offset: int = ...,
count: Optional[int] = ...,
*,
fallback: bool = ...,
self, transport: BaseTransport, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool = ...
) -> int: ...
async def start_tls(
self,
@@ -265,15 +248,15 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
sslcontext: ssl.SSLContext,
*,
server_side: bool = ...,
server_hostname: Optional[str] = ...,
ssl_handshake_timeout: Optional[float] = ...,
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
) -> BaseTransport: ...
else:
@overload
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: Optional[Union[str, Sequence[str]]] = ...,
host: str | Sequence[str] | None = ...,
port: int = ...,
*,
family: int = ...,
@@ -281,8 +264,8 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
sock: None = ...,
backlog: int = ...,
ssl: _SSLContext = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...,
reuse_address: bool | None = ...,
reuse_port: bool | None = ...,
) -> Server: ...
@overload
async def create_server(
@@ -296,8 +279,8 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
sock: socket,
backlog: int = ...,
ssl: _SSLContext = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...,
reuse_address: bool | None = ...,
reuse_port: bool | None = ...,
) -> Server: ...
async def connect_accepted_socket(
self, protocol_factory: _ProtocolFactory, sock: socket, *, ssl: _SSLContext = ...
@@ -305,16 +288,16 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
async def create_datagram_endpoint(
self,
protocol_factory: _ProtocolFactory,
local_addr: Optional[Tuple[str, int]] = ...,
remote_addr: Optional[Tuple[str, int]] = ...,
local_addr: Tuple[str, int] | None = ...,
remote_addr: Tuple[str, int] | None = ...,
*,
family: int = ...,
proto: int = ...,
flags: int = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...,
allow_broadcast: Optional[bool] = ...,
sock: Optional[socket] = ...,
reuse_address: bool | None = ...,
reuse_port: bool | None = ...,
allow_broadcast: bool | None = ...,
sock: socket | None = ...,
) -> _TransProtPair: ...
# Pipes and subprocesses.
async def connect_read_pipe(self, protocol_factory: _ProtocolFactory, pipe: Any) -> _TransProtPair: ...
@@ -322,11 +305,11 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
async def subprocess_shell(
self,
protocol_factory: _ProtocolFactory,
cmd: Union[bytes, str],
cmd: bytes | str,
*,
stdin: Union[int, IO[Any], None] = ...,
stdout: Union[int, IO[Any], None] = ...,
stderr: Union[int, IO[Any], None] = ...,
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] = ...,
@@ -340,9 +323,9 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
protocol_factory: _ProtocolFactory,
program: Any,
*args: Any,
stdin: Union[int, IO[Any], None] = ...,
stdout: Union[int, IO[Any], None] = ...,
stderr: Union[int, IO[Any], None] = ...,
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] = ...,
@@ -370,8 +353,8 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
def add_signal_handler(self, sig: int, callback: Callable[..., Any], *args: Any) -> None: ...
def remove_signal_handler(self, sig: int) -> bool: ...
# Error handlers.
def set_exception_handler(self, handler: Optional[_ExceptionHandler]) -> None: ...
def get_exception_handler(self) -> Optional[_ExceptionHandler]: ...
def set_exception_handler(self, handler: _ExceptionHandler | None) -> None: ...
def get_exception_handler(self) -> _ExceptionHandler | None: ...
def default_exception_handler(self, context: _Context) -> None: ...
def call_exception_handler(self, context: _Context) -> None: ...
# Debug flag management.

View File

@@ -10,9 +10,9 @@ 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
_proc: subprocess.Popen[Any] | None # undocumented
_pid: int | None # undocumented
_returncode: int | None # undocumented
_exit_waiters: List[futures.Future[Any]] # undocumented
_pending_calls: Deque[Tuple[Callable[..., Any], Tuple[Any, ...]]] # undocumented
_pipes: Dict[int, _File] # undocumented
@@ -21,19 +21,19 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
self,
loop: events.AbstractEventLoop,
protocol: protocols.SubprocessProtocol,
args: Union[str, bytes, Sequence[Union[str, bytes]]],
args: str | bytes | Sequence[str | bytes],
shell: bool,
stdin: _File,
stdout: _File,
stderr: _File,
bufsize: int,
waiter: Optional[futures.Future[Any]] = ...,
extra: Optional[Any] = ...,
waiter: futures.Future[Any] | None = ...,
extra: Any | None = ...,
**kwargs: Any,
) -> None: ...
def _start(
self,
args: Union[str, bytes, Sequence[Union[str, bytes]]],
args: str | bytes | Sequence[str | bytes],
shell: bool,
stdin: _File,
stdout: _File,
@@ -45,26 +45,26 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
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_pid(self) -> int | None: ... # type: ignore
def get_returncode(self) -> int | None: ...
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
async def _connect_pipes(self, waiter: futures.Future[Any] | None) -> 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_connection_lost(self, fd: int, exc: BaseException | None) -> 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
def _call_connection_lost(self, exc: BaseException | None) -> 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 connection_lost(self, exc: BaseException | None) -> None: ...
def pause_writing(self) -> None: ...
def resume_writing(self) -> None: ...

View File

@@ -1,9 +1,9 @@
from _typeshed import StrOrBytesPath
from types import FrameType
from typing import Any, List, Optional
from typing import Any, List
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: StrOrBytesPath) -> None: ... # undocumented
def _task_get_stack(task: tasks.Task[Any], limit: int | None) -> List[FrameType]: ... # undocumented
def _task_print_stack(task: tasks.Task[Any], limit: int | None, file: StrOrBytesPath) -> None: ... # undocumented

View File

@@ -3,7 +3,7 @@ import sys
from _typeshed import FileDescriptorLike, Self
from abc import ABCMeta, abstractmethod
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 import IO, Any, Awaitable, Callable, Dict, Generator, List, Sequence, Tuple, TypeVar, Union, overload
from typing_extensions import Literal
from .base_events import Server
@@ -28,7 +28,7 @@ class Handle:
_args: Sequence[Any]
if sys.version_info >= (3, 7):
def __init__(
self, callback: Callable[..., Any], args: Sequence[Any], loop: AbstractEventLoop, context: Optional[Context] = ...
self, callback: Callable[..., Any], args: Sequence[Any], loop: AbstractEventLoop, context: Context | None = ...
) -> None: ...
else:
def __init__(self, callback: Callable[..., Any], args: Sequence[Any], loop: AbstractEventLoop) -> None: ...
@@ -46,7 +46,7 @@ class TimerHandle(Handle):
callback: Callable[..., Any],
args: Sequence[Any],
loop: AbstractEventLoop,
context: Optional[Context] = ...,
context: Context | None = ...,
) -> None: ...
else:
def __init__(self, when: float, callback: Callable[..., Any], args: Sequence[Any], loop: AbstractEventLoop) -> None: ...
@@ -101,16 +101,14 @@ class AbstractEventLoop(metaclass=ABCMeta):
# 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]: ...
def create_task(self, coro: Awaitable[_T] | Generator[Any, None, _T], *, name: str | None = ...) -> Task[_T]: ...
else:
@abstractmethod
def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ...
def create_task(self, coro: 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: ...
def set_task_factory(self, factory: Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]] | None) -> None: ...
@abstractmethod
def get_task_factory(self) -> Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]: ...
def get_task_factory(self) -> Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]] | None: ...
# Methods for interacting with threads
@abstractmethod
def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any) -> Handle: ...
@@ -121,19 +119,10 @@ class AbstractEventLoop(metaclass=ABCMeta):
# 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]]]]: ...
self, host: str | None, port: str | int | None, *, family: int = ..., type: int = ..., proto: int = ..., flags: int = ...
) -> List[Tuple[AddressFamily, SocketKind, int, str, 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]: ...
async def getnameinfo(self, sockaddr: Tuple[str, int] | Tuple[str, int, int, int], flags: int = ...) -> Tuple[str, str]: ...
if sys.version_info >= (3, 8):
@overload
@abstractmethod
@@ -148,11 +137,11 @@ class AbstractEventLoop(metaclass=ABCMeta):
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] = ...,
local_addr: Tuple[str, int] | None = ...,
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
happy_eyeballs_delay: float | None = ...,
interleave: int | None = ...,
) -> _TransProtPair: ...
@overload
@abstractmethod
@@ -168,10 +157,10 @@ class AbstractEventLoop(metaclass=ABCMeta):
flags: int = ...,
sock: socket,
local_addr: None = ...,
server_hostname: Optional[str] = ...,
ssl_handshake_timeout: Optional[float] = ...,
happy_eyeballs_delay: Optional[float] = ...,
interleave: Optional[int] = ...,
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
happy_eyeballs_delay: float | None = ...,
interleave: int | None = ...,
) -> _TransProtPair: ...
elif sys.version_info >= (3, 7):
@overload
@@ -187,9 +176,9 @@ class AbstractEventLoop(metaclass=ABCMeta):
proto: int = ...,
flags: int = ...,
sock: None = ...,
local_addr: Optional[Tuple[str, int]] = ...,
server_hostname: Optional[str] = ...,
ssl_handshake_timeout: Optional[float] = ...,
local_addr: Tuple[str, int] | None = ...,
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
) -> _TransProtPair: ...
@overload
@abstractmethod
@@ -205,8 +194,8 @@ class AbstractEventLoop(metaclass=ABCMeta):
flags: int = ...,
sock: socket,
local_addr: None = ...,
server_hostname: Optional[str] = ...,
ssl_handshake_timeout: Optional[float] = ...,
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
) -> _TransProtPair: ...
else:
@overload
@@ -222,8 +211,8 @@ class AbstractEventLoop(metaclass=ABCMeta):
proto: int = ...,
flags: int = ...,
sock: None = ...,
local_addr: Optional[Tuple[str, int]] = ...,
server_hostname: Optional[str] = ...,
local_addr: Tuple[str, int] | None = ...,
server_hostname: str | None = ...,
) -> _TransProtPair: ...
@overload
@abstractmethod
@@ -239,19 +228,19 @@ class AbstractEventLoop(metaclass=ABCMeta):
flags: int = ...,
sock: socket,
local_addr: None = ...,
server_hostname: Optional[str] = ...,
server_hostname: str | None = ...,
) -> _TransProtPair: ...
if sys.version_info >= (3, 7):
@abstractmethod
async def sock_sendfile(
self, sock: socket, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *, fallback: Optional[bool] = ...
self, sock: socket, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool | None = ...
) -> int: ...
@overload
@abstractmethod
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: Optional[Union[str, Sequence[str]]] = ...,
host: str | Sequence[str] | None = ...,
port: int = ...,
*,
family: int = ...,
@@ -259,9 +248,9 @@ class AbstractEventLoop(metaclass=ABCMeta):
sock: None = ...,
backlog: int = ...,
ssl: _SSLContext = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...,
ssl_handshake_timeout: Optional[float] = ...,
reuse_address: bool | None = ...,
reuse_port: bool | None = ...,
ssl_handshake_timeout: float | None = ...,
start_serving: bool = ...,
) -> Server: ...
@overload
@@ -277,41 +266,35 @@ class AbstractEventLoop(metaclass=ABCMeta):
sock: socket = ...,
backlog: int = ...,
ssl: _SSLContext = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...,
ssl_handshake_timeout: Optional[float] = ...,
reuse_address: bool | None = ...,
reuse_port: bool | None = ...,
ssl_handshake_timeout: float | None = ...,
start_serving: bool = ...,
) -> Server: ...
async def create_unix_connection(
self,
protocol_factory: _ProtocolFactory,
path: Optional[str] = ...,
path: str | None = ...,
*,
ssl: _SSLContext = ...,
sock: Optional[socket] = ...,
server_hostname: Optional[str] = ...,
ssl_handshake_timeout: Optional[float] = ...,
sock: socket | None = ...,
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
) -> _TransProtPair: ...
async def create_unix_server(
self,
protocol_factory: _ProtocolFactory,
path: Optional[str] = ...,
path: str | None = ...,
*,
sock: Optional[socket] = ...,
sock: socket | None = ...,
backlog: int = ...,
ssl: _SSLContext = ...,
ssl_handshake_timeout: Optional[float] = ...,
ssl_handshake_timeout: float | None = ...,
start_serving: bool = ...,
) -> Server: ...
@abstractmethod
async def sendfile(
self,
transport: BaseTransport,
file: IO[bytes],
offset: int = ...,
count: Optional[int] = ...,
*,
fallback: bool = ...,
self, transport: BaseTransport, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool = ...
) -> int: ...
@abstractmethod
async def start_tls(
@@ -321,8 +304,8 @@ class AbstractEventLoop(metaclass=ABCMeta):
sslcontext: ssl.SSLContext,
*,
server_side: bool = ...,
server_hostname: Optional[str] = ...,
ssl_handshake_timeout: Optional[float] = ...,
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
) -> BaseTransport: ...
else:
@overload
@@ -330,7 +313,7 @@ class AbstractEventLoop(metaclass=ABCMeta):
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: Optional[Union[str, Sequence[str]]] = ...,
host: str | Sequence[str] | None = ...,
port: int = ...,
*,
family: int = ...,
@@ -338,8 +321,8 @@ class AbstractEventLoop(metaclass=ABCMeta):
sock: None = ...,
backlog: int = ...,
ssl: _SSLContext = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...,
reuse_address: bool | None = ...,
reuse_port: bool | None = ...,
) -> Server: ...
@overload
@abstractmethod
@@ -354,8 +337,8 @@ class AbstractEventLoop(metaclass=ABCMeta):
sock: socket,
backlog: int = ...,
ssl: _SSLContext = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...,
reuse_address: bool | None = ...,
reuse_port: bool | None = ...,
) -> Server: ...
async def create_unix_connection(
self,
@@ -363,15 +346,15 @@ class AbstractEventLoop(metaclass=ABCMeta):
path: str,
*,
ssl: _SSLContext = ...,
sock: Optional[socket] = ...,
server_hostname: Optional[str] = ...,
sock: socket | None = ...,
server_hostname: str | None = ...,
) -> _TransProtPair: ...
async def create_unix_server(
self,
protocol_factory: _ProtocolFactory,
path: str,
*,
sock: Optional[socket] = ...,
sock: socket | None = ...,
backlog: int = ...,
ssl: _SSLContext = ...,
) -> Server: ...
@@ -379,16 +362,16 @@ class AbstractEventLoop(metaclass=ABCMeta):
async def create_datagram_endpoint(
self,
protocol_factory: _ProtocolFactory,
local_addr: Optional[Tuple[str, int]] = ...,
remote_addr: Optional[Tuple[str, int]] = ...,
local_addr: Tuple[str, int] | None = ...,
remote_addr: Tuple[str, int] | None = ...,
*,
family: int = ...,
proto: int = ...,
flags: int = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...,
allow_broadcast: Optional[bool] = ...,
sock: Optional[socket] = ...,
reuse_address: bool | None = ...,
reuse_port: bool | None = ...,
allow_broadcast: bool | None = ...,
sock: socket | None = ...,
) -> _TransProtPair: ...
# Pipes and subprocesses.
@abstractmethod
@@ -399,11 +382,11 @@ class AbstractEventLoop(metaclass=ABCMeta):
async def subprocess_shell(
self,
protocol_factory: _ProtocolFactory,
cmd: Union[bytes, str],
cmd: bytes | str,
*,
stdin: Union[int, IO[Any], None] = ...,
stdout: Union[int, IO[Any], None] = ...,
stderr: Union[int, IO[Any], None] = ...,
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] = ...,
@@ -418,9 +401,9 @@ class AbstractEventLoop(metaclass=ABCMeta):
protocol_factory: _ProtocolFactory,
program: Any,
*args: Any,
stdin: Union[int, IO[Any], None] = ...,
stdout: Union[int, IO[Any], None] = ...,
stderr: Union[int, IO[Any], None] = ...,
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] = ...,
@@ -464,9 +447,9 @@ class AbstractEventLoop(metaclass=ABCMeta):
def remove_signal_handler(self, sig: int) -> bool: ...
# Error handlers.
@abstractmethod
def set_exception_handler(self, handler: Optional[_ExceptionHandler]) -> None: ...
def set_exception_handler(self, handler: _ExceptionHandler | None) -> None: ...
@abstractmethod
def get_exception_handler(self) -> Optional[_ExceptionHandler]: ...
def get_exception_handler(self) -> _ExceptionHandler | None: ...
@abstractmethod
def default_exception_handler(self, context: _Context) -> None: ...
@abstractmethod
@@ -484,7 +467,7 @@ class AbstractEventLoopPolicy(metaclass=ABCMeta):
@abstractmethod
def get_event_loop(self) -> AbstractEventLoop: ...
@abstractmethod
def set_event_loop(self, loop: Optional[AbstractEventLoop]) -> None: ...
def set_event_loop(self, loop: AbstractEventLoop | None) -> None: ...
@abstractmethod
def new_event_loop(self) -> AbstractEventLoop: ...
# Child processes handling (Unix only).
@@ -496,17 +479,17 @@ class AbstractEventLoopPolicy(metaclass=ABCMeta):
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 set_event_loop(self, loop: AbstractEventLoop | None) -> None: ...
def new_event_loop(self) -> AbstractEventLoop: ...
def get_event_loop_policy() -> AbstractEventLoopPolicy: ...
def set_event_loop_policy(policy: Optional[AbstractEventLoopPolicy]) -> None: ...
def set_event_loop_policy(policy: AbstractEventLoopPolicy | None) -> None: ...
def get_event_loop() -> AbstractEventLoop: ...
def set_event_loop(loop: Optional[AbstractEventLoop]) -> None: ...
def set_event_loop(loop: AbstractEventLoop | None) -> 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 _set_running_loop(__loop: AbstractEventLoop | None) -> None: ...
def _get_running_loop() -> AbstractEventLoop: ...
if sys.version_info >= (3, 7):

View File

@@ -1,5 +1,4 @@
import sys
from typing import Optional
if sys.version_info >= (3, 8):
class CancelledError(BaseException): ...
@@ -7,9 +6,9 @@ if sys.version_info >= (3, 8):
class InvalidStateError(Exception): ...
class SendfileNotAvailableError(RuntimeError): ...
class IncompleteReadError(EOFError):
expected: Optional[int]
expected: int | None
partial: bytes
def __init__(self, partial: bytes, expected: Optional[int]) -> None: ...
def __init__(self, partial: bytes, expected: int | None) -> None: ...
class LimitOverrunError(Exception):
consumed: int
def __init__(self, message: str, consumed: int) -> None: ...

View File

@@ -2,10 +2,10 @@ import functools
import sys
import traceback
from types import FrameType, FunctionType
from typing import Any, Dict, Iterable, Optional, Tuple, Union, overload
from typing import Any, Dict, Iterable, Tuple, Union, overload
class _HasWrapper:
__wrapper__: Union[_HasWrapper, FunctionType]
__wrapper__: _HasWrapper | FunctionType
_FuncType = Union[FunctionType, _HasWrapper, functools.partial[Any], functools.partialmethod[Any]]
@@ -13,8 +13,8 @@ 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 _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: Optional[FrameType] = ..., limit: Optional[int] = ...) -> traceback.StackSummary: ...
def extract_stack(f: FrameType | None = ..., limit: int | None = ...) -> traceback.StackSummary: ...

View File

@@ -1,6 +1,6 @@
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 typing import Any, Awaitable, Callable, Generator, Iterable, List, Tuple, TypeVar
from .events import AbstractEventLoop
@@ -33,28 +33,28 @@ class Future(Awaitable[_T], Iterable[_T]):
_exception: BaseException
_blocking = False
_log_traceback = False
def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
def __init__(self, *, loop: AbstractEventLoop | None = ...) -> 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: ...
def add_done_callback(self: _S, __fn: Callable[[_S], Any], *, context: Context | None = ...) -> 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: ...
def cancel(self, msg: str | None = ...) -> bool: ...
else:
def cancel(self) -> bool: ...
def cancelled(self) -> bool: ...
def done(self) -> bool: ...
def result(self) -> _T: ...
def exception(self) -> Optional[BaseException]: ...
def exception(self) -> BaseException | None: ...
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 set_exception(self, __exception: type | BaseException) -> None: ...
def __iter__(self) -> Generator[Any, None, _T]: ...
def __await__(self) -> Generator[Any, None, _T]: ...
@property
@@ -62,4 +62,4 @@ class Future(Awaitable[_T], Iterable[_T]):
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]: ...
def wrap_future(future: _ConcurrentFuture[_T] | Future[_T], *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ...

View File

@@ -1,6 +1,6 @@
import sys
from types import TracebackType
from typing import Any, Awaitable, Callable, Deque, Generator, Optional, Type, TypeVar, Union
from typing import Any, Awaitable, Callable, Deque, Generator, Type, TypeVar
from .events import AbstractEventLoop
from .futures import Future
@@ -9,19 +9,19 @@ _T = TypeVar("_T")
if sys.version_info >= (3, 9):
class _ContextManagerMixin:
def __init__(self, lock: Union[Lock, Semaphore]) -> None: ...
def __init__(self, lock: Lock | Semaphore) -> None: ...
def __aenter__(self) -> Awaitable[None]: ...
def __aexit__(
self, exc_type: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType]
self, exc_type: Type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
) -> Awaitable[None]: ...
else:
class _ContextManager:
def __init__(self, lock: Union[Lock, Semaphore]) -> None: ...
def __init__(self, lock: Lock | Semaphore) -> None: ...
def __enter__(self) -> object: ...
def __exit__(self, *args: Any) -> None: ...
class _ContextManagerMixin:
def __init__(self, lock: Union[Lock, Semaphore]) -> None: ...
def __init__(self, lock: Lock | Semaphore) -> None: ...
# Apparently this exists to *prohibit* use as a context manager.
def __enter__(self) -> object: ...
def __exit__(self, *args: Any) -> None: ...
@@ -29,24 +29,24 @@ else:
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]
self, exc_type: Type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
) -> Awaitable[None]: ...
class Lock(_ContextManagerMixin):
def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
def __init__(self, *, loop: AbstractEventLoop | None = ...) -> None: ...
def locked(self) -> bool: ...
async def acquire(self) -> bool: ...
def release(self) -> None: ...
class Event:
def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
def __init__(self, *, loop: AbstractEventLoop | None = ...) -> 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 __init__(self, lock: Lock | None = ..., *, loop: AbstractEventLoop | None = ...) -> None: ...
def locked(self) -> bool: ...
async def acquire(self) -> bool: ...
def release(self) -> None: ...
@@ -58,11 +58,11 @@ class Condition(_ContextManagerMixin):
class Semaphore(_ContextManagerMixin):
_value: int
_waiters: Deque[Future[Any]]
def __init__(self, value: int = ..., *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
def __init__(self, value: int = ..., *, loop: AbstractEventLoop | None = ...) -> 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: ...
def __init__(self, value: int = ..., *, loop: AbstractEventLoop | None = ...) -> None: ...

View File

@@ -1,6 +1,6 @@
import sys
from socket import socket
from typing import Any, Mapping, Optional, Type
from typing import Any, Mapping, Type
from typing_extensions import Literal, Protocol
from . import base_events, constants, events, futures, streams, transports
@@ -8,7 +8,7 @@ from . import base_events, constants, events, futures, streams, transports
if sys.version_info >= (3, 8):
class _WarnCallbackProtocol(Protocol):
def __call__(
self, message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ..., source: Optional[Any] = ...
self, message: str, category: Type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ...
) -> None: ...
class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTransport):
@@ -17,9 +17,9 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTr
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: Optional[futures.Future[Any]] = ...,
extra: Optional[Mapping[Any, Any]] = ...,
server: Optional[events.AbstractServer] = ...,
waiter: futures.Future[Any] | None = ...,
extra: Mapping[Any, Any] | None = ...,
server: events.AbstractServer | None = ...,
) -> None: ...
def __repr__(self) -> str: ...
if sys.version_info >= (3, 8):
@@ -34,9 +34,9 @@ class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTran
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: Optional[futures.Future[Any]] = ...,
extra: Optional[Mapping[Any, Any]] = ...,
server: Optional[events.AbstractServer] = ...,
waiter: futures.Future[Any] | None = ...,
extra: Mapping[Any, Any] | None = ...,
server: events.AbstractServer | None = ...,
) -> None: ...
class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.WriteTransport):
@@ -45,9 +45,9 @@ class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.Wri
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: Optional[futures.Future[Any]] = ...,
extra: Optional[Mapping[Any, Any]] = ...,
server: Optional[events.AbstractServer] = ...,
waiter: futures.Future[Any] | None = ...,
extra: Mapping[Any, Any] | None = ...,
server: events.AbstractServer | None = ...,
) -> None: ...
class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport):
@@ -56,9 +56,9 @@ class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport):
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: Optional[futures.Future[Any]] = ...,
extra: Optional[Mapping[Any, Any]] = ...,
server: Optional[events.AbstractServer] = ...,
waiter: futures.Future[Any] | None = ...,
extra: Mapping[Any, Any] | None = ...,
server: events.AbstractServer | None = ...,
) -> None: ...
class _ProactorDuplexPipeTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport): ...
@@ -71,9 +71,9 @@ class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePip
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: Optional[futures.Future[Any]] = ...,
extra: Optional[Mapping[Any, Any]] = ...,
server: Optional[events.AbstractServer] = ...,
waiter: futures.Future[Any] | None = ...,
extra: Mapping[Any, Any] | None = ...,
server: events.AbstractServer | None = ...,
) -> None: ...
def _set_extra(self, sock: socket) -> None: ...
def can_write_eof(self) -> Literal[True]: ...

View File

@@ -1,16 +1,16 @@
import sys
from asyncio import transports
from typing import Optional, Tuple
from typing import Tuple
class BaseProtocol:
def connection_made(self, transport: transports.BaseTransport) -> None: ...
def connection_lost(self, exc: Optional[Exception]) -> None: ...
def connection_lost(self, exc: Exception | None) -> 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]: ...
def eof_received(self) -> bool | None: ...
if sys.version_info >= (3, 7):
class BufferedProtocol(BaseProtocol):
@@ -23,5 +23,5 @@ class DatagramProtocol(BaseProtocol):
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 pipe_connection_lost(self, fd: int, exc: Exception | None) -> None: ...
def process_exited(self) -> None: ...

View File

@@ -1,6 +1,6 @@
import sys
from asyncio.events import AbstractEventLoop
from typing import Any, Generic, Optional, TypeVar
from typing import Any, Generic, TypeVar
if sys.version_info >= (3, 9):
from types import GenericAlias
@@ -11,7 +11,7 @@ class QueueFull(Exception): ...
_T = TypeVar("_T")
class Queue(Generic[_T]):
def __init__(self, maxsize: int = ..., *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
def __init__(self, maxsize: int = ..., *, loop: AbstractEventLoop | None = ...) -> None: ...
def _init(self, maxsize: int) -> None: ...
def _get(self) -> _T: ...
def _put(self, item: _T) -> None: ...

View File

@@ -1,10 +1,10 @@
import sys
if sys.version_info >= (3, 7):
from typing import Awaitable, Optional, TypeVar
from typing import Awaitable, TypeVar
_T = TypeVar("_T")
if sys.version_info >= (3, 8):
def run(main: Awaitable[_T], *, debug: Optional[bool] = ...) -> _T: ...
def run(main: Awaitable[_T], *, debug: bool | None = ...) -> _T: ...
else:
def run(main: Awaitable[_T], *, debug: bool = ...) -> _T: ...

View File

@@ -1,7 +1,6 @@
import selectors
from typing import Optional
from . import base_events
class BaseSelectorEventLoop(base_events.BaseEventLoop):
def __init__(self, selector: Optional[selectors.BaseSelector] = ...) -> None: ...
def __init__(self, selector: selectors.BaseSelector | None = ...) -> None: ...

View File

@@ -1,11 +1,11 @@
import ssl
import sys
from typing import Any, Callable, ClassVar, Deque, Dict, List, Optional, Tuple
from typing import Any, Callable, ClassVar, Deque, Dict, List, 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: ...
def _create_transport_context(server_side: bool, server_hostname: str | None) -> ssl.SSLContext: ...
_UNWRAPPED: Literal["UNWRAPPED"]
_DO_HANDSHAKE: Literal["DO_HANDSHAKE"]
@@ -18,25 +18,25 @@ class _SSLPipe:
_context: ssl.SSLContext
_server_side: bool
_server_hostname: Optional[str]
_server_hostname: str | None
_state: str
_incoming: ssl.MemoryBIO
_outgoing: ssl.MemoryBIO
_sslobj: Optional[ssl.SSLObject]
_sslobj: ssl.SSLObject | None
_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: ...
_handshake_cb: Callable[[BaseException | None], None] | None
_shutdown_cb: Callable[[], None] | None
def __init__(self, context: ssl.SSLContext, server_side: bool, server_hostname: str | None = ...) -> None: ...
@property
def context(self) -> ssl.SSLContext: ...
@property
def ssl_object(self) -> Optional[ssl.SSLObject]: ...
def ssl_object(self) -> ssl.SSLObject | None: ...
@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 do_handshake(self, callback: Callable[[BaseException | None], None] | None = ...) -> List[bytes]: ...
def shutdown(self, callback: Callable[[], None] | 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]: ...
@@ -49,7 +49,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: Optional[Any] = ...) -> Dict[str, Any]: ...
def get_extra_info(self, name: str, default: Any | None = ...) -> Dict[str, Any]: ...
def set_protocol(self, protocol: protocols.BaseProtocol) -> None: ...
def get_protocol(self) -> protocols.BaseProtocol: ...
def is_closing(self) -> bool: ...
@@ -58,7 +58,7 @@ class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport):
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 set_write_buffer_limits(self, high: int | None = ..., low: int | None = ...) -> None: ...
def get_write_buffer_size(self) -> int: ...
if sys.version_info >= (3, 7):
@property
@@ -70,7 +70,7 @@ class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport):
class SSLProtocol(protocols.Protocol):
_server_side: bool
_server_hostname: Optional[str]
_server_hostname: str | None
_sslcontext: ssl.SSLContext
_extra: Dict[str, Any]
_write_backlog: Deque[Tuple[bytes, int]]
@@ -78,13 +78,13 @@ class SSLProtocol(protocols.Protocol):
_waiter: futures.Future[Any]
_loop: events.AbstractEventLoop
_app_transport: _SSLProtocolTransport
_sslpipe: Optional[_SSLPipe]
_sslpipe: _SSLPipe | None
_session_established: bool
_in_handshake: bool
_in_shutdown: bool
_transport: Optional[transports.BaseTransport]
_transport: transports.BaseTransport | None
_call_connection_made: bool
_ssl_handshake_timeout: Optional[int]
_ssl_handshake_timeout: int | None
_app_protocol: protocols.BaseProtocol
_app_protocol_is_buffer: bool
@@ -96,9 +96,9 @@ class SSLProtocol(protocols.Protocol):
sslcontext: ssl.SSLContext,
waiter: futures.Future[Any],
server_side: bool = ...,
server_hostname: Optional[str] = ...,
server_hostname: str | None = ...,
call_connection_made: bool = ...,
ssl_handshake_timeout: Optional[int] = ...,
ssl_handshake_timeout: int | None = ...,
) -> None: ...
else:
def __init__(
@@ -108,25 +108,25 @@ class SSLProtocol(protocols.Protocol):
sslcontext: ssl.SSLContext,
waiter: futures.Future[Any],
server_side: bool = ...,
server_hostname: Optional[str] = ...,
server_hostname: str | None = ...,
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 _wakeup_waiter(self, exc: BaseException | None = ...) -> None: ...
def connection_made(self, transport: transports.BaseTransport) -> None: ...
def connection_lost(self, exc: Optional[BaseException]) -> None: ...
def connection_lost(self, exc: BaseException | None) -> 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 _get_extra_info(self, name: str, default: Any | None = ...) -> 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 _on_handshake_complete(self, handshake_exc: BaseException | None) -> None: ...
def _process_write_backlog(self) -> None: ...
def _fatal_error(self, exc: BaseException, message: str = ...) -> None: ...
def _finalize(self) -> None: ...

View File

@@ -1,12 +1,9 @@
import sys
from typing import Any, Awaitable, Callable, Iterable, List, Optional, Tuple
from typing import Any, Awaitable, Callable, Iterable, List, 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]]]: ...
coro_fns: Iterable[Callable[[], Awaitable[Any]]], delay: float | None, *, loop: events.AbstractEventLoop | None = ...
) -> Tuple[Any, int | None, List[Exception | None]]: ...

View File

@@ -1,6 +1,6 @@
import sys
from _typeshed import StrPath
from typing import Any, AsyncIterator, Awaitable, Callable, Iterable, Optional, Tuple, Union
from typing import Any, AsyncIterator, Awaitable, Callable, Iterable, Optional, Tuple
from . import events, protocols, transports
from .base_events import Server
@@ -9,30 +9,30 @@ _ClientConnectedCallback = Callable[[StreamReader, StreamWriter], Optional[Await
if sys.version_info < (3, 8):
class IncompleteReadError(EOFError):
expected: Optional[int]
expected: int | None
partial: bytes
def __init__(self, partial: bytes, expected: Optional[int]) -> None: ...
def __init__(self, partial: bytes, expected: int | None) -> 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]] = ...,
host: str | None = ...,
port: int | str | None = ...,
*,
loop: Optional[events.AbstractEventLoop] = ...,
loop: events.AbstractEventLoop | None = ...,
limit: int = ...,
ssl_handshake_timeout: Optional[float] = ...,
ssl_handshake_timeout: float | None = ...,
**kwds: Any,
) -> Tuple[StreamReader, StreamWriter]: ...
async def start_server(
client_connected_cb: _ClientConnectedCallback,
host: Optional[str] = ...,
port: Optional[Union[int, str]] = ...,
host: str | None = ...,
port: int | str | None = ...,
*,
loop: Optional[events.AbstractEventLoop] = ...,
loop: events.AbstractEventLoop | None = ...,
limit: int = ...,
ssl_handshake_timeout: Optional[float] = ...,
ssl_handshake_timeout: float | None = ...,
**kwds: Any,
) -> Server: ...
@@ -42,29 +42,29 @@ if sys.platform != "win32":
else:
_PathType = str
async def open_unix_connection(
path: Optional[_PathType] = ..., *, loop: Optional[events.AbstractEventLoop] = ..., limit: int = ..., **kwds: Any
path: _PathType | None = ..., *, loop: events.AbstractEventLoop | None = ..., limit: int = ..., **kwds: Any
) -> Tuple[StreamReader, StreamWriter]: ...
async def start_unix_server(
client_connected_cb: _ClientConnectedCallback,
path: Optional[_PathType] = ...,
path: _PathType | None = ...,
*,
loop: Optional[events.AbstractEventLoop] = ...,
loop: events.AbstractEventLoop | None = ...,
limit: int = ...,
**kwds: Any,
) -> Server: ...
class FlowControlMixin(protocols.Protocol):
def __init__(self, loop: Optional[events.AbstractEventLoop] = ...) -> None: ...
def __init__(self, loop: events.AbstractEventLoop | None = ...) -> None: ...
class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
def __init__(
self,
stream_reader: StreamReader,
client_connected_cb: Optional[_ClientConnectedCallback] = ...,
loop: Optional[events.AbstractEventLoop] = ...,
client_connected_cb: _ClientConnectedCallback | None = ...,
loop: events.AbstractEventLoop | None = ...,
) -> None: ...
def connection_made(self, transport: transports.BaseTransport) -> None: ...
def connection_lost(self, exc: Optional[Exception]) -> None: ...
def connection_lost(self, exc: Exception | None) -> None: ...
def data_received(self, data: bytes) -> None: ...
def eof_received(self) -> bool: ...
@@ -73,7 +73,7 @@ class StreamWriter:
self,
transport: transports.BaseTransport,
protocol: protocols.BaseProtocol,
reader: Optional[StreamReader],
reader: StreamReader | None,
loop: events.AbstractEventLoop,
) -> None: ...
@property
@@ -90,7 +90,7 @@ class StreamWriter:
async def drain(self) -> None: ...
class StreamReader:
def __init__(self, limit: int = ..., loop: Optional[events.AbstractEventLoop] = ...) -> None: ...
def __init__(self, limit: int = ..., loop: events.AbstractEventLoop | None = ...) -> None: ...
def exception(self) -> Exception: ...
def set_exception(self, exc: Exception) -> None: ...
def set_transport(self, transport: transports.BaseTransport) -> None: ...

View File

@@ -2,7 +2,7 @@ import subprocess
import sys
from _typeshed import StrOrBytesPath
from asyncio import events, protocols, streams, transports
from typing import IO, Any, Callable, Optional, Tuple, Union
from typing import IO, Any, Callable, Tuple, Union
from typing_extensions import Literal
if sys.version_info >= (3, 8):
@@ -15,37 +15,37 @@ STDOUT: int
DEVNULL: int
class SubprocessStreamProtocol(streams.FlowControlMixin, protocols.SubprocessProtocol):
stdin: Optional[streams.StreamWriter]
stdout: Optional[streams.StreamReader]
stderr: Optional[streams.StreamReader]
stdin: streams.StreamWriter | None
stdout: streams.StreamReader | None
stderr: streams.StreamReader | None
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 pipe_data_received(self, fd: int, data: bytes | str) -> None: ...
def pipe_connection_lost(self, fd: int, exc: Exception | None) -> None: ...
def process_exited(self) -> None: ...
class Process:
stdin: Optional[streams.StreamWriter]
stdout: Optional[streams.StreamReader]
stderr: Optional[streams.StreamReader]
stdin: streams.StreamWriter | None
stdout: streams.StreamReader | None
stderr: streams.StreamReader | None
pid: int
def __init__(
self, transport: transports.BaseTransport, protocol: protocols.BaseProtocol, loop: events.AbstractEventLoop
) -> None: ...
@property
def returncode(self) -> Optional[int]: ...
def returncode(self) -> int | None: ...
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 communicate(self, input: bytes | None = ...) -> Tuple[bytes, bytes]: ...
if sys.version_info >= (3, 10):
async def create_subprocess_shell(
cmd: Union[str, bytes],
stdin: Union[int, IO[Any], None] = ...,
stdout: Union[int, IO[Any], None] = ...,
stderr: Union[int, IO[Any], None] = ...,
cmd: str | bytes,
stdin: int | IO[Any] | None = ...,
stdout: int | IO[Any] | None = ...,
stderr: int | IO[Any] | None = ...,
limit: int = ...,
*,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
@@ -56,12 +56,12 @@ if sys.version_info >= (3, 10):
errors: None = ...,
text: Literal[False, None] = ...,
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
executable: Optional[StrOrBytesPath] = ...,
preexec_fn: Optional[Callable[[], Any]] = ...,
executable: StrOrBytesPath | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
cwd: Optional[StrOrBytesPath] = ...,
env: Optional[subprocess._ENV] = ...,
startupinfo: Optional[Any] = ...,
cwd: StrOrBytesPath | None = ...,
env: subprocess._ENV | None = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
@@ -70,9 +70,9 @@ if sys.version_info >= (3, 10):
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] = ...,
stdin: int | IO[Any] | None = ...,
stdout: int | IO[Any] | None = ...,
stderr: int | IO[Any] | None = ...,
limit: int = ...,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
universal_newlines: Literal[False] = ...,
@@ -81,13 +81,13 @@ if sys.version_info >= (3, 10):
encoding: None = ...,
errors: None = ...,
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
text: Optional[bool] = ...,
executable: Optional[StrOrBytesPath] = ...,
preexec_fn: Optional[Callable[[], Any]] = ...,
text: bool | None = ...,
executable: StrOrBytesPath | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
cwd: Optional[StrOrBytesPath] = ...,
env: Optional[subprocess._ENV] = ...,
startupinfo: Optional[Any] = ...,
cwd: StrOrBytesPath | None = ...,
env: subprocess._ENV | None = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
@@ -96,11 +96,11 @@ if sys.version_info >= (3, 10):
else:
async def create_subprocess_shell(
cmd: Union[str, bytes],
stdin: Union[int, IO[Any], None] = ...,
stdout: Union[int, IO[Any], None] = ...,
stderr: Union[int, IO[Any], None] = ...,
loop: Optional[events.AbstractEventLoop] = ...,
cmd: str | bytes,
stdin: int | IO[Any] | None = ...,
stdout: int | IO[Any] | None = ...,
stderr: int | IO[Any] | None = ...,
loop: events.AbstractEventLoop | None = ...,
limit: int = ...,
*,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
@@ -111,12 +111,12 @@ else:
errors: None = ...,
text: Literal[False, None] = ...,
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
executable: Optional[StrOrBytesPath] = ...,
preexec_fn: Optional[Callable[[], Any]] = ...,
executable: StrOrBytesPath | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
cwd: Optional[StrOrBytesPath] = ...,
env: Optional[subprocess._ENV] = ...,
startupinfo: Optional[Any] = ...,
cwd: StrOrBytesPath | None = ...,
env: subprocess._ENV | None = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
@@ -125,10 +125,10 @@ else:
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] = ...,
stdin: int | IO[Any] | None = ...,
stdout: int | IO[Any] | None = ...,
stderr: int | IO[Any] | None = ...,
loop: events.AbstractEventLoop | None = ...,
limit: int = ...,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
universal_newlines: Literal[False] = ...,
@@ -137,13 +137,13 @@ else:
encoding: None = ...,
errors: None = ...,
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
text: Optional[bool] = ...,
executable: Optional[StrOrBytesPath] = ...,
preexec_fn: Optional[Callable[[], Any]] = ...,
text: bool | None = ...,
executable: StrOrBytesPath | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
cwd: Optional[StrOrBytesPath] = ...,
env: Optional[subprocess._ENV] = ...,
startupinfo: Optional[Any] = ...,
cwd: StrOrBytesPath | None = ...,
env: subprocess._ENV | None = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,

View File

@@ -2,10 +2,10 @@ import sys
from asyncio.events import AbstractEventLoop
from asyncio.protocols import BaseProtocol
from socket import _Address
from typing import Any, List, Mapping, Optional, Tuple
from typing import Any, List, Mapping, Tuple
class BaseTransport:
def __init__(self, extra: Optional[Mapping[Any, Any]] = ...) -> None: ...
def __init__(self, extra: Mapping[Any, Any] | None = ...) -> None: ...
def get_extra_info(self, name: Any, default: Any = ...) -> Any: ...
def is_closing(self) -> bool: ...
def close(self) -> None: ...
@@ -19,7 +19,7 @@ class ReadTransport(BaseTransport):
def resume_reading(self) -> None: ...
class WriteTransport(BaseTransport):
def set_write_buffer_limits(self, high: Optional[int] = ..., low: Optional[int] = ...) -> None: ...
def set_write_buffer_limits(self, high: int | None = ..., low: int | None = ...) -> None: ...
def get_write_buffer_size(self) -> int: ...
def write(self, data: Any) -> None: ...
def writelines(self, list_of_data: List[Any]) -> None: ...
@@ -30,17 +30,17 @@ class WriteTransport(BaseTransport):
class Transport(ReadTransport, WriteTransport): ...
class DatagramTransport(BaseTransport):
def sendto(self, data: Any, addr: Optional[_Address] = ...) -> None: ...
def sendto(self, data: Any, addr: _Address | None = ...) -> 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 get_returncode(self) -> int | None: ...
def get_pipe_transport(self, fd: int) -> BaseTransport | None: ...
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 __init__(self, extra: Mapping[Any, Any] | None = ..., loop: AbstractEventLoop | None = ...) -> None: ...
def get_write_buffer_limits(self) -> Tuple[int, int]: ...

View File

@@ -1,7 +1,7 @@
import socket
import sys
from types import TracebackType
from typing import Any, BinaryIO, Iterable, List, NoReturn, Optional, Tuple, Type, Union, overload
from typing import Any, BinaryIO, Iterable, List, NoReturn, Tuple, Type, Union, overload
if sys.version_info >= (3, 8):
# These are based in socket, maybe move them out into _typeshed.pyi or such
@@ -28,23 +28,23 @@ if sys.version_info >= (3, 8):
@overload
def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ...
@overload
def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ...
def setsockopt(self, level: int, optname: int, value: 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: ...
def connect(self, address: _Address | bytes) -> None: ...
def connect_ex(self, address: _Address | bytes) -> int: ...
def bind(self, address: _Address | bytes) -> None: ...
if sys.platform == "win32":
def ioctl(self, control: int, option: Union[int, Tuple[int, int, int], bool]) -> None: ...
def ioctl(self, control: int, option: int | Tuple[int, int, int] | bool) -> None: ...
else:
def ioctl(self, control: int, option: Union[int, Tuple[int, int, int], bool]) -> NoReturn: ...
def ioctl(self, control: int, option: 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 sendfile(self, file: BinaryIO, offset: int = ..., count: int | None = ...) -> int: ...
def close(self) -> None: ...
def detach(self) -> int: ...
if sys.platform == "linux":
@@ -77,10 +77,10 @@ if sys.version_info >= (3, 8):
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 settimeout(self, value: float | None) -> None: ...
def gettimeout(self) -> float | None: ...
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]
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...

View File

@@ -2,7 +2,7 @@ import sys
import types
from _typeshed import Self
from socket import socket
from typing import Any, Callable, Optional, Type
from typing import Any, Callable, Type
from .base_events import Server
from .events import AbstractEventLoop, BaseDefaultEventLoopPolicy, _ProtocolFactory, _SSLContext
@@ -11,12 +11,10 @@ from .selector_events import BaseSelectorEventLoop
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 attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
def close(self) -> None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(
self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType]
) -> None: ...
def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ...
if sys.version_info >= (3, 8):
def is_active(self) -> bool: ...
@@ -34,16 +32,16 @@ class _UnixSelectorEventLoop(BaseSelectorEventLoop):
async def create_unix_server(
self,
protocol_factory: _ProtocolFactory,
path: Optional[str] = ...,
path: str | None = ...,
*,
sock: Optional[socket] = ...,
sock: socket | None = ...,
backlog: int = ...,
ssl: _SSLContext = ...,
) -> Server: ...
class _UnixDefaultEventLoopPolicy(BaseDefaultEventLoopPolicy):
def get_child_watcher(self) -> AbstractChildWatcher: ...
def set_child_watcher(self, watcher: Optional[AbstractChildWatcher]) -> None: ...
def set_child_watcher(self, watcher: AbstractChildWatcher | None) -> None: ...
SelectorEventLoop = _UnixSelectorEventLoop
@@ -54,7 +52,7 @@ if sys.version_info >= (3, 8):
from typing import Protocol
class _Warn(Protocol):
def __call__(
self, message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ..., source: Optional[Any] = ...
self, message: str, category: Type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ...
) -> None: ...
class MultiLoopChildWatcher(AbstractChildWatcher):
def __enter__(self: Self) -> Self: ...

View File

@@ -1,7 +1,7 @@
import socket
import sys
from _typeshed import WriteableBuffer
from typing import IO, Any, Callable, ClassVar, List, NoReturn, Optional, Tuple, Type
from typing import IO, Any, Callable, ClassVar, List, NoReturn, Tuple, Type
from . import events, futures, proactor_events, selector_events, streams, windows_utils
@@ -30,7 +30,7 @@ class PipeServer:
class _WindowsSelectorEventLoop(selector_events.BaseSelectorEventLoop): ...
class ProactorEventLoop(proactor_events.BaseProactorEventLoop):
def __init__(self, proactor: Optional[IocpProactor] = ...) -> None: ...
def __init__(self, proactor: IocpProactor | None = ...) -> None: ...
async def create_pipe_connection(
self, protocol_factory: Callable[[], streams.StreamReaderProtocol], address: str
) -> Tuple[proactor_events._ProactorDuplexPipeTransport, streams.StreamReaderProtocol]: ...
@@ -43,7 +43,7 @@ class IocpProactor:
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 select(self, timeout: int | None = ...) -> 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: WriteableBuffer, flags: int = ...) -> futures.Future[Any]: ...
@@ -54,7 +54,7 @@ class IocpProactor:
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 wait_for_handle(self, handle: windows_utils.PipeHandle, timeout: int | None = ...) -> bool: ...
def close(self) -> None: ...
SelectorEventLoop = _WindowsSelectorEventLoop

View File

@@ -1,7 +1,7 @@
import sys
from _typeshed import Self
from types import TracebackType
from typing import Callable, Optional, Protocol, Tuple, Type
from typing import Callable, Protocol, Tuple, Type
class _WarnFunction(Protocol):
def __call__(self, message: str, category: Type[Warning] = ..., stacklevel: int = ..., source: PipeHandle = ...) -> None: ...
@@ -20,7 +20,7 @@ class PipeHandle:
else:
def __del__(self) -> None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(self, t: Optional[type], v: Optional[BaseException], tb: Optional[TracebackType]) -> None: ...
def __exit__(self, t: type | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
@property
def handle(self) -> int: ...
def fileno(self) -> int: ...