Remove Python 3.6 branches from typeshed (#8269)

This commit is contained in:
Alex Waygood
2022-07-11 09:55:17 +01:00
committed by GitHub
parent 29c17ffb47
commit edc0ecd857
114 changed files with 1016 additions and 2642 deletions

View File

@@ -3,6 +3,7 @@ import sys
from _typeshed import FileDescriptorLike, Self, WriteableBuffer
from abc import ABCMeta, abstractmethod
from collections.abc import Awaitable, Callable, Coroutine, Generator, Sequence
from contextvars import Context
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
from typing import IO, Any, Protocol, TypeVar, overload
from typing_extensions import Literal, TypeAlias
@@ -14,9 +15,6 @@ from .tasks import Task
from .transports import BaseTransport, ReadTransport, SubprocessTransport, WriteTransport
from .unix_events import AbstractChildWatcher
if sys.version_info >= (3, 7):
from contextvars import Context
if sys.version_info >= (3, 8):
__all__ = (
"AbstractEventLoopPolicy",
@@ -36,7 +34,7 @@ if sys.version_info >= (3, 8):
"_get_running_loop",
)
elif sys.version_info >= (3, 7):
else:
__all__ = (
"AbstractEventLoopPolicy",
"AbstractEventLoop",
@@ -56,24 +54,6 @@ elif sys.version_info >= (3, 7):
"_get_running_loop",
)
else:
__all__ = [
"AbstractEventLoopPolicy",
"AbstractEventLoop",
"AbstractServer",
"Handle",
"TimerHandle",
"get_event_loop_policy",
"set_event_loop_policy",
"get_event_loop",
"set_event_loop",
"new_event_loop",
"get_child_watcher",
"set_child_watcher",
"_set_running_loop",
"_get_running_loop",
]
_T = TypeVar("_T")
_ProtocolT = TypeVar("_ProtocolT", bound=BaseProtocol)
_Context: TypeAlias = dict[str, Any]
@@ -89,35 +69,24 @@ class _TaskFactory(Protocol):
class Handle:
_cancelled: bool
_args: Sequence[Any]
if sys.version_info >= (3, 7):
def __init__(
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: ...
def __init__(
self, callback: Callable[..., Any], args: Sequence[Any], loop: AbstractEventLoop, context: Context | None = ...
) -> None: ...
def cancel(self) -> None: ...
def _run(self) -> None: ...
if sys.version_info >= (3, 7):
def cancelled(self) -> bool: ...
def cancelled(self) -> bool: ...
class TimerHandle(Handle):
if sys.version_info >= (3, 7):
def __init__(
self,
when: float,
callback: Callable[..., Any],
args: Sequence[Any],
loop: AbstractEventLoop,
context: Context | None = ...,
) -> None: ...
else:
def __init__(self, when: float, callback: Callable[..., Any], args: Sequence[Any], loop: AbstractEventLoop) -> None: ...
def __init__(
self,
when: float,
callback: Callable[..., Any],
args: Sequence[Any],
loop: AbstractEventLoop,
context: Context | None = ...,
) -> None: ...
def __hash__(self) -> int: ...
if sys.version_info >= (3, 7):
def when(self) -> float: ...
def when(self) -> float: ...
def __lt__(self, other: TimerHandle) -> bool: ...
def __le__(self, other: TimerHandle) -> bool: ...
def __gt__(self, other: TimerHandle) -> bool: ...
@@ -127,18 +96,16 @@ class TimerHandle(Handle):
class AbstractServer:
@abstractmethod
def close(self) -> None: ...
if sys.version_info >= (3, 7):
async def __aenter__(self: Self) -> Self: ...
async def __aexit__(self, *exc: object) -> None: ...
@abstractmethod
def get_loop(self) -> AbstractEventLoop: ...
@abstractmethod
def is_serving(self) -> bool: ...
@abstractmethod
async def start_serving(self) -> None: ...
@abstractmethod
async def serve_forever(self) -> None: ...
async def __aenter__(self: Self) -> Self: ...
async def __aexit__(self, *exc: object) -> None: ...
@abstractmethod
def get_loop(self) -> AbstractEventLoop: ...
@abstractmethod
def is_serving(self) -> bool: ...
@abstractmethod
async def start_serving(self) -> None: ...
@abstractmethod
async def serve_forever(self) -> None: ...
@abstractmethod
async def wait_closed(self) -> None: ...
@@ -317,41 +284,6 @@ class AbstractEventLoop:
happy_eyeballs_delay: float | None = ...,
interleave: int | None = ...,
) -> tuple[BaseTransport, _ProtocolT]: ...
elif sys.version_info >= (3, 7):
@overload
@abstractmethod
async def create_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
host: str = ...,
port: int = ...,
*,
ssl: _SSLContext = ...,
family: int = ...,
proto: int = ...,
flags: int = ...,
sock: None = ...,
local_addr: tuple[str, int] | None = ...,
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
) -> tuple[BaseTransport, _ProtocolT]: ...
@overload
@abstractmethod
async def create_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
host: None = ...,
port: None = ...,
*,
ssl: _SSLContext = ...,
family: int = ...,
proto: int = ...,
flags: int = ...,
sock: socket,
local_addr: None = ...,
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
) -> tuple[BaseTransport, _ProtocolT]: ...
else:
@overload
@abstractmethod
@@ -368,6 +300,7 @@ class AbstractEventLoop:
sock: None = ...,
local_addr: tuple[str, int] | None = ...,
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
) -> tuple[BaseTransport, _ProtocolT]: ...
@overload
@abstractmethod
@@ -384,6 +317,7 @@ class AbstractEventLoop:
sock: socket,
local_addr: None = ...,
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
) -> tuple[BaseTransport, _ProtocolT]: ...
if sys.version_info >= (3, 11):
@overload
@@ -448,7 +382,7 @@ class AbstractEventLoop:
ssl_shutdown_timeout: float | None = ...,
start_serving: bool = ...,
) -> Server: ...
elif sys.version_info >= (3, 7):
else:
@overload
@abstractmethod
async def create_server(
@@ -507,48 +441,6 @@ class AbstractEventLoop:
ssl_handshake_timeout: float | None = ...,
start_serving: bool = ...,
) -> Server: ...
else:
@overload
@abstractmethod
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str] | None = ...,
port: int = ...,
*,
family: int = ...,
flags: int = ...,
sock: None = ...,
backlog: int = ...,
ssl: _SSLContext = ...,
reuse_address: bool | None = ...,
reuse_port: bool | None = ...,
) -> Server: ...
@overload
@abstractmethod
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: None = ...,
port: None = ...,
*,
family: int = ...,
flags: int = ...,
sock: socket,
backlog: int = ...,
ssl: _SSLContext = ...,
reuse_address: bool | None = ...,
reuse_port: bool | None = ...,
) -> Server: ...
async def create_unix_server(
self,
protocol_factory: _ProtocolFactory,
path: str,
*,
sock: socket | None = ...,
backlog: int = ...,
ssl: _SSLContext = ...,
) -> Server: ...
if sys.version_info >= (3, 11):
async def connect_accepted_socket(
self,
@@ -580,7 +472,7 @@ class AbstractEventLoop:
ssl_handshake_timeout: float | None = ...,
ssl_shutdown_timeout: float | None = ...,
) -> tuple[BaseTransport, _ProtocolT]: ...
elif sys.version_info >= (3, 7):
else:
async def create_unix_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
@@ -591,26 +483,15 @@ class AbstractEventLoop:
server_hostname: str | None = ...,
ssl_handshake_timeout: float | None = ...,
) -> tuple[BaseTransport, _ProtocolT]: ...
else:
async def create_unix_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
path: str,
*,
ssl: _SSLContext = ...,
sock: socket | None = ...,
server_hostname: str | None = ...,
) -> tuple[BaseTransport, _ProtocolT]: ...
if sys.version_info >= (3, 7):
@abstractmethod
async def sock_sendfile(
self, sock: socket, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool | None = ...
) -> int: ...
@abstractmethod
async def sendfile(
self, transport: BaseTransport, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool = ...
) -> int: ...
@abstractmethod
async def sock_sendfile(
self, sock: socket, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool | None = ...
) -> int: ...
@abstractmethod
async def sendfile(
self, transport: BaseTransport, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool = ...
) -> int: ...
@abstractmethod
async def create_datagram_endpoint(
self,
@@ -677,26 +558,16 @@ class AbstractEventLoop:
@abstractmethod
def remove_writer(self, fd: FileDescriptorLike) -> bool: ...
# Completion based I/O methods returning Futures prior to 3.7
if sys.version_info >= (3, 7):
@abstractmethod
async def sock_recv(self, sock: socket, nbytes: int) -> bytes: ...
@abstractmethod
async def sock_recv_into(self, sock: socket, buf: WriteableBuffer) -> int: ...
@abstractmethod
async def sock_sendall(self, sock: socket, data: bytes) -> None: ...
@abstractmethod
async def sock_connect(self, sock: socket, address: _Address) -> None: ...
@abstractmethod
async def sock_accept(self, sock: socket) -> tuple[socket, _RetAddress]: ...
else:
@abstractmethod
def sock_recv(self, sock: socket, nbytes: int) -> Future[bytes]: ...
@abstractmethod
def sock_sendall(self, sock: socket, data: bytes) -> Future[None]: ...
@abstractmethod
def sock_connect(self, sock: socket, address: _Address) -> Future[None]: ...
@abstractmethod
def sock_accept(self, sock: socket) -> Future[tuple[socket, _RetAddress]]: ...
@abstractmethod
async def sock_recv(self, sock: socket, nbytes: int) -> bytes: ...
@abstractmethod
async def sock_recv_into(self, sock: socket, buf: WriteableBuffer) -> int: ...
@abstractmethod
async def sock_sendall(self, sock: socket, data: bytes) -> None: ...
@abstractmethod
async def sock_connect(self, sock: socket, address: _Address) -> None: ...
@abstractmethod
async def sock_accept(self, sock: socket) -> tuple[socket, _RetAddress]: ...
if sys.version_info >= (3, 11):
@abstractmethod
async def sock_recvfrom(self, sock: socket, bufsize: int) -> bytes: ...
@@ -755,8 +626,7 @@ def get_child_watcher() -> AbstractChildWatcher: ...
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...
def _set_running_loop(__loop: AbstractEventLoop | None) -> None: ...
def _get_running_loop() -> AbstractEventLoop: ...
def get_running_loop() -> AbstractEventLoop: ...
if sys.version_info >= (3, 7):
def get_running_loop() -> AbstractEventLoop: ...
if sys.version_info < (3, 8):
class SendfileNotAvailableError(RuntimeError): ...
if sys.version_info < (3, 8):
class SendfileNotAvailableError(RuntimeError): ...