Use PEP 585 syntax wherever possible (#6717)

This commit is contained in:
Alex Waygood
2021-12-28 10:31:43 +00:00
committed by GitHub
parent e6cb341d94
commit 8d5d2520ac
237 changed files with 966 additions and 1069 deletions

View File

@@ -9,18 +9,18 @@ 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, Sequence, Tuple, TypeVar, Union, overload
from typing import IO, Any, Awaitable, Callable, Generator, Sequence, TypeVar, Union, overload
from typing_extensions import Literal
if sys.version_info >= (3, 7):
from contextvars import Context
_T = TypeVar("_T")
_Context = Dict[str, Any]
_Context = dict[str, Any]
_ExceptionHandler = Callable[[AbstractEventLoop, _Context], Any]
_ProtocolFactory = Callable[[], BaseProtocol]
_SSLContext = Union[bool, None, ssl.SSLContext]
_TransProtPair = Tuple[BaseTransport, BaseProtocol]
_TransProtPair = tuple[BaseTransport, BaseProtocol]
class Server(AbstractServer):
if sys.version_info >= (3, 7):
@@ -37,7 +37,7 @@ class Server(AbstractServer):
def __init__(self, loop: AbstractEventLoop, sockets: list[socket]) -> None: ...
if sys.version_info >= (3, 8):
@property
def sockets(self) -> Tuple[socket, ...]: ...
def sockets(self) -> tuple[socket, ...]: ...
elif sys.version_info >= (3, 7):
@property
def sockets(self) -> list[socket]: ...

View File

@@ -1,6 +1,6 @@
import subprocess
from collections import deque
from typing import IO, Any, Callable, Optional, Sequence, Tuple, Union
from typing import IO, Any, Callable, Optional, Sequence, Union
from . import events, futures, protocols, transports
@@ -15,7 +15,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
_pid: int | None # undocumented
_returncode: int | None # undocumented
_exit_waiters: list[futures.Future[Any]] # undocumented
_pending_calls: deque[tuple[Callable[..., Any], Tuple[Any, ...]]] # undocumented
_pending_calls: deque[tuple[Callable[..., Any], tuple[Any, ...]]] # undocumented
_pipes: dict[int, _File] # undocumented
_finished: bool # undocumented
def __init__(

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, Sequence, Tuple, TypeVar, Union, overload
from typing import IO, Any, Awaitable, Callable, Generator, Sequence, TypeVar, Union, overload
from typing_extensions import Literal
from .base_events import Server
@@ -17,11 +17,11 @@ if sys.version_info >= (3, 7):
from contextvars import Context
_T = TypeVar("_T")
_Context = Dict[str, Any]
_Context = dict[str, Any]
_ExceptionHandler = Callable[[AbstractEventLoop, _Context], Any]
_ProtocolFactory = Callable[[], BaseProtocol]
_SSLContext = Union[bool, None, ssl.SSLContext]
_TransProtPair = Tuple[BaseTransport, BaseProtocol]
_TransProtPair = tuple[BaseTransport, BaseProtocol]
class Handle:
_cancelled = False

View File

@@ -1,14 +1,14 @@
import socket
import sys
from types import TracebackType
from typing import Any, BinaryIO, Iterable, NoReturn, Tuple, Type, Union, overload
from typing import Any, BinaryIO, Iterable, NoReturn, Type, Union, overload
if sys.version_info >= (3, 8):
# These are based in socket, maybe move them out into _typeshed.pyi or such
_Address = Union[Tuple[Any, ...], str]
_Address = Union[tuple[Any, ...], str]
_RetAddress = Any
_WriteBuffer = Union[bytearray, memoryview]
_CMSG = Tuple[int, int, bytes]
_CMSG = tuple[int, int, bytes]
class TransportSocket:
def __init__(self, sock: socket.socket) -> None: ...
def _na(self, what: str) -> None: ...