mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-04-24 16:06:26 +08:00
Use TypeAlias where possible for type aliases (#7630)
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import codecs
|
||||
import sys
|
||||
from typing import Any, Callable
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
# This type is not exposed; it is defined in unicodeobject.c
|
||||
class _EncodingMap:
|
||||
def size(self) -> int: ...
|
||||
|
||||
_MapT = dict[int, int] | _EncodingMap
|
||||
_Handler = Callable[[Exception], tuple[str, int]]
|
||||
_MapT: TypeAlias = dict[int, int] | _EncodingMap
|
||||
_Handler: TypeAlias = Callable[[Exception], tuple[str, int]]
|
||||
|
||||
def register(__search_function: Callable[[str], Any]) -> None: ...
|
||||
def register_error(__errors: str, __handler: _Handler) -> None: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from typing import Any, Iterable, Iterator, Protocol, Union
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
__version__: str
|
||||
|
||||
@@ -21,7 +21,7 @@ class Dialect:
|
||||
strict: int
|
||||
def __init__(self) -> None: ...
|
||||
|
||||
_DialectLike = Union[str, Dialect, type[Dialect]]
|
||||
_DialectLike: TypeAlias = Union[str, Dialect, type[Dialect]]
|
||||
|
||||
class _reader(Iterator[list[str]]):
|
||||
dialect: Dialect
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import sys
|
||||
from _typeshed import SupportsRead
|
||||
from typing import IO, Any, NamedTuple, overload
|
||||
from typing_extensions import final
|
||||
from typing_extensions import TypeAlias, final
|
||||
|
||||
if sys.platform != "win32":
|
||||
_chtype = str | bytes | int
|
||||
_chtype: TypeAlias = str | bytes | int
|
||||
|
||||
# ACS codes are only initialized after initscr is called
|
||||
ACS_BBSS: int
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import sys
|
||||
from types import FrameType, TracebackType
|
||||
from typing import Any, Callable, Iterable, Mapping, TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
# TODO recursive type
|
||||
_TF = Callable[[FrameType, str, Any], Callable[..., Any] | None]
|
||||
_TF: TypeAlias = Callable[[FrameType, str, Any], Callable[..., Any] | None]
|
||||
|
||||
_PF = Callable[[FrameType, str, Any], None]
|
||||
_PF: TypeAlias = Callable[[FrameType, str, Any], None]
|
||||
_T = TypeVar("_T")
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
|
||||
@@ -15,7 +15,7 @@ from typing import (
|
||||
TypeVar,
|
||||
overload,
|
||||
)
|
||||
from typing_extensions import ParamSpec, SupportsIndex, final
|
||||
from typing_extensions import ParamSpec, SupportsIndex, TypeAlias, final
|
||||
|
||||
_R = TypeVar("_R")
|
||||
_T = TypeVar("_T")
|
||||
@@ -40,7 +40,7 @@ class _SupportsDunderLE(Protocol):
|
||||
class _SupportsDunderGE(Protocol):
|
||||
def __ge__(self, __other: Any) -> Any: ...
|
||||
|
||||
_SupportsComparison = _SupportsDunderLE | _SupportsDunderGE | _SupportsDunderGT | _SupportsDunderLT
|
||||
_SupportsComparison: TypeAlias = _SupportsDunderLE | _SupportsDunderGE | _SupportsDunderGT | _SupportsDunderLT
|
||||
|
||||
class _SupportsInversion(Protocol[_T_co]):
|
||||
def __invert__(self) -> _T_co: ...
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
# Actually Tuple[(int,) * 625]
|
||||
_State = tuple[int, ...]
|
||||
_State: TypeAlias = tuple[int, ...]
|
||||
|
||||
class Random:
|
||||
def __init__(self, seed: object = ...) -> None: ...
|
||||
|
||||
@@ -2,20 +2,21 @@ import sys
|
||||
from _typeshed import ReadableBuffer, WriteableBuffer
|
||||
from collections.abc import Iterable
|
||||
from typing import Any, SupportsInt, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import SupportsIndex
|
||||
|
||||
_FD = SupportsIndex
|
||||
_FD: TypeAlias = SupportsIndex
|
||||
else:
|
||||
_FD = SupportsInt
|
||||
_FD: TypeAlias = SupportsInt
|
||||
|
||||
_CMSG = tuple[int, int, bytes]
|
||||
_CMSGArg = tuple[int, int, ReadableBuffer]
|
||||
_CMSG: TypeAlias = tuple[int, int, bytes]
|
||||
_CMSGArg: TypeAlias = tuple[int, int, ReadableBuffer]
|
||||
|
||||
# Addresses can be either tuples of varying lengths (AF_INET, AF_INET6,
|
||||
# AF_NETLINK, AF_TIPC) or strings (AF_UNIX).
|
||||
_Address = tuple[Any, ...] | str
|
||||
_Address: TypeAlias = tuple[Any, ...] | str
|
||||
_RetAddress = Any
|
||||
# TODO Most methods allow bytes as address objects
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from typing import Any
|
||||
from typing_extensions import TypeAlias
|
||||
from weakref import ReferenceType
|
||||
|
||||
__all__ = ["local"]
|
||||
localdict = dict[Any, Any]
|
||||
localdict: TypeAlias = dict[Any, Any]
|
||||
|
||||
class _localimpl:
|
||||
key: str
|
||||
|
||||
@@ -99,7 +99,7 @@ StrPath: TypeAlias = str | PathLike[str] # stable
|
||||
BytesPath: TypeAlias = bytes | PathLike[bytes] # stable
|
||||
StrOrBytesPath: TypeAlias = str | bytes | PathLike[str] | PathLike[bytes] # stable
|
||||
|
||||
OpenTextModeUpdating = Literal[
|
||||
OpenTextModeUpdating: TypeAlias = Literal[
|
||||
"r+",
|
||||
"+r",
|
||||
"rt+",
|
||||
|
||||
@@ -2,7 +2,7 @@ import sys
|
||||
from _typeshed import Self
|
||||
from types import TracebackType
|
||||
from typing import IO, Any, NamedTuple, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
__all__ = ["Error", "open"]
|
||||
@@ -19,8 +19,8 @@ class _aifc_params(NamedTuple):
|
||||
comptype: bytes
|
||||
compname: bytes
|
||||
|
||||
_File = str | IO[bytes]
|
||||
_Marker = tuple[int, int, bytes]
|
||||
_File: TypeAlias = str | IO[bytes]
|
||||
_Marker: TypeAlias = tuple[int, int, bytes]
|
||||
|
||||
class Aifc_read:
|
||||
def __init__(self, f: _File) -> None: ...
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import sys
|
||||
from _typeshed import Self
|
||||
from typing import Any, BinaryIO, Generic, Iterable, MutableSequence, TypeVar, overload
|
||||
from typing_extensions import Literal, SupportsIndex
|
||||
from typing_extensions import Literal, SupportsIndex, TypeAlias
|
||||
|
||||
_IntTypeCode = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"]
|
||||
_FloatTypeCode = Literal["f", "d"]
|
||||
_UnicodeTypeCode = Literal["u"]
|
||||
_TypeCode = _IntTypeCode | _FloatTypeCode | _UnicodeTypeCode
|
||||
_IntTypeCode: TypeAlias = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"]
|
||||
_FloatTypeCode: TypeAlias = Literal["f", "d"]
|
||||
_UnicodeTypeCode: TypeAlias = Literal["u"]
|
||||
_TypeCode: TypeAlias = _IntTypeCode | _FloatTypeCode | _UnicodeTypeCode
|
||||
|
||||
_T = TypeVar("_T", int, float, str)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ from asyncio.transports import BaseTransport, ReadTransport, SubprocessTransport
|
||||
from collections.abc import Iterable
|
||||
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
|
||||
from typing import IO, Any, Awaitable, Callable, Coroutine, Generator, Sequence, TypeVar, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from contextvars import Context
|
||||
@@ -23,10 +23,10 @@ else:
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_ProtocolT = TypeVar("_ProtocolT", bound=BaseProtocol)
|
||||
_Context = dict[str, Any]
|
||||
_ExceptionHandler = Callable[[AbstractEventLoop, _Context], Any]
|
||||
_ProtocolFactory = Callable[[], BaseProtocol]
|
||||
_SSLContext = bool | None | ssl.SSLContext
|
||||
_Context: TypeAlias = dict[str, Any]
|
||||
_ExceptionHandler: TypeAlias = Callable[[AbstractEventLoop, _Context], Any]
|
||||
_ProtocolFactory: TypeAlias = Callable[[], BaseProtocol]
|
||||
_SSLContext: TypeAlias = bool | None | ssl.SSLContext
|
||||
|
||||
class Server(AbstractServer):
|
||||
if sys.version_info >= (3, 7):
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import subprocess
|
||||
from collections import deque
|
||||
from typing import IO, Any, Callable, Sequence
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from . import events, futures, protocols, transports
|
||||
|
||||
_File = int | IO[Any] | None
|
||||
_File: TypeAlias = int | IO[Any] | None
|
||||
|
||||
class BaseSubprocessTransport(transports.SubprocessTransport):
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ 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, Coroutine, Generator, Sequence, TypeVar, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from .base_events import Server
|
||||
from .futures import Future
|
||||
@@ -75,10 +75,10 @@ else:
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_ProtocolT = TypeVar("_ProtocolT", bound=BaseProtocol)
|
||||
_Context = dict[str, Any]
|
||||
_ExceptionHandler = Callable[[AbstractEventLoop, _Context], Any]
|
||||
_ProtocolFactory = Callable[[], BaseProtocol]
|
||||
_SSLContext = bool | None | ssl.SSLContext
|
||||
_Context: TypeAlias = dict[str, Any]
|
||||
_ExceptionHandler: TypeAlias = Callable[[AbstractEventLoop, _Context], Any]
|
||||
_ProtocolFactory: TypeAlias = Callable[[], BaseProtocol]
|
||||
_SSLContext: TypeAlias = bool | None | ssl.SSLContext
|
||||
|
||||
class Handle:
|
||||
_cancelled: bool
|
||||
|
||||
@@ -2,11 +2,12 @@ import functools
|
||||
import traceback
|
||||
from types import FrameType, FunctionType
|
||||
from typing import Any, Iterable, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
class _HasWrapper:
|
||||
__wrapper__: _HasWrapper | FunctionType
|
||||
|
||||
_FuncType = FunctionType | _HasWrapper | functools.partial[Any] | functools.partialmethod[Any]
|
||||
_FuncType: TypeAlias = FunctionType | _HasWrapper | functools.partial[Any] | functools.partialmethod[Any]
|
||||
|
||||
@overload
|
||||
def _get_function_source(func: _FuncType) -> tuple[str, int]: ...
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import sys
|
||||
from _typeshed import Self, StrPath
|
||||
from typing import Any, AsyncIterator, Awaitable, Callable, Iterable, Sequence
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from . import events, protocols, transports
|
||||
from .base_events import Server
|
||||
@@ -64,7 +65,7 @@ else:
|
||||
"start_unix_server",
|
||||
]
|
||||
|
||||
_ClientConnectedCallback = Callable[[StreamReader, StreamWriter], Awaitable[None] | None]
|
||||
_ClientConnectedCallback: TypeAlias = Callable[[StreamReader, StreamWriter], Awaitable[None] | None]
|
||||
|
||||
if sys.version_info < (3, 8):
|
||||
class IncompleteReadError(EOFError):
|
||||
|
||||
@@ -3,7 +3,7 @@ import sys
|
||||
from _typeshed import StrOrBytesPath
|
||||
from asyncio import events, protocols, streams, transports
|
||||
from typing import IO, Any, Callable
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
__all__ = ("create_subprocess_exec", "create_subprocess_shell")
|
||||
@@ -11,9 +11,9 @@ else:
|
||||
__all__ = ["create_subprocess_exec", "create_subprocess_shell"]
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
_ExecArg = StrOrBytesPath
|
||||
_ExecArg: TypeAlias = StrOrBytesPath
|
||||
else:
|
||||
_ExecArg = str | bytes
|
||||
_ExecArg: TypeAlias = str | bytes
|
||||
|
||||
PIPE: int
|
||||
STDOUT: int
|
||||
|
||||
@@ -3,7 +3,7 @@ import sys
|
||||
from collections.abc import Awaitable, Generator, Iterable, Iterator
|
||||
from types import FrameType
|
||||
from typing import Any, Coroutine, Generic, TextIO, TypeVar, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from .events import AbstractEventLoop
|
||||
from .futures import Future
|
||||
@@ -56,8 +56,8 @@ _T3 = TypeVar("_T3")
|
||||
_T4 = TypeVar("_T4")
|
||||
_T5 = TypeVar("_T5")
|
||||
_FT = TypeVar("_FT", bound=Future[Any])
|
||||
_FutureT = Future[_T] | Generator[Any, None, _T] | Awaitable[_T]
|
||||
_TaskYieldType = Future[object] | None
|
||||
_FutureT: TypeAlias = Future[_T] | Generator[Any, None, _T] | Awaitable[_T]
|
||||
_TaskYieldType: TypeAlias = Future[object] | None
|
||||
|
||||
FIRST_COMPLETED = concurrent.futures.FIRST_COMPLETED
|
||||
FIRST_EXCEPTION = concurrent.futures.FIRST_EXCEPTION
|
||||
|
||||
@@ -3,12 +3,13 @@ import sys
|
||||
from builtins import type as Type # alias to avoid name clashes with property named "type"
|
||||
from types import TracebackType
|
||||
from typing import Any, BinaryIO, Iterable, NoReturn, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
# These are based in socket, maybe move them out into _typeshed.pyi or such
|
||||
_Address = tuple[Any, ...] | str
|
||||
_RetAddress = Any
|
||||
_WriteBuffer = bytearray | memoryview
|
||||
_CMSG = tuple[int, int, bytes]
|
||||
_Address: TypeAlias = tuple[Any, ...] | str
|
||||
_RetAddress: TypeAlias = Any
|
||||
_WriteBuffer: TypeAlias = bytearray | memoryview
|
||||
_CMSG: TypeAlias = tuple[int, int, bytes]
|
||||
|
||||
class TransportSocket:
|
||||
def __init__(self, sock: socket.socket) -> None: ...
|
||||
|
||||
@@ -2,10 +2,11 @@ import sys
|
||||
from _typeshed import FileDescriptorLike
|
||||
from socket import socket
|
||||
from typing import Any, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
# cyclic dependence with asynchat
|
||||
_maptype = dict[int, Any]
|
||||
_socket = socket
|
||||
_maptype: TypeAlias = dict[int, Any]
|
||||
_socket: TypeAlias = socket
|
||||
|
||||
socket_map: _maptype # undocumented
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
AdpcmState = tuple[int, int]
|
||||
RatecvState = tuple[int, tuple[tuple[int, int], ...]]
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
AdpcmState: TypeAlias = tuple[int, int]
|
||||
RatecvState: TypeAlias = tuple[int, tuple[tuple[int, int], ...]]
|
||||
|
||||
class error(Exception): ...
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
from types import CodeType, FrameType, TracebackType
|
||||
from typing import IO, Any, Callable, Iterable, Mapping, SupportsInt, TypeVar
|
||||
from typing_extensions import Literal, ParamSpec
|
||||
from typing_extensions import Literal, ParamSpec, TypeAlias
|
||||
|
||||
__all__ = ["BdbQuit", "Bdb", "Breakpoint"]
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_P = ParamSpec("_P")
|
||||
_TraceDispatch = Callable[[FrameType, str, Any], Any] # TODO: Recursive type
|
||||
_ExcInfo = tuple[type[BaseException], BaseException, FrameType]
|
||||
_TraceDispatch: TypeAlias = Callable[[FrameType, str, Any], Any] # TODO: Recursive type
|
||||
_ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, FrameType]
|
||||
|
||||
GENERATOR_AND_COROUTINE_FLAGS: Literal[672]
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from typing import IO, Any
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
__all__ = ["binhex", "hexbin", "Error"]
|
||||
|
||||
@@ -15,8 +15,8 @@ class FInfo:
|
||||
Creator: str
|
||||
Flags: int
|
||||
|
||||
_FileInfoTuple = tuple[str, FInfo, int, int]
|
||||
_FileHandleUnion = str | IO[bytes]
|
||||
_FileInfoTuple: TypeAlias = tuple[str, FInfo, int, int]
|
||||
_FileHandleUnion: TypeAlias = str | IO[bytes]
|
||||
|
||||
def getfileinfo(name: str) -> _FileInfoTuple: ...
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ from typing import (
|
||||
TypeVar,
|
||||
overload,
|
||||
)
|
||||
from typing_extensions import Literal, SupportsIndex, TypeGuard, final
|
||||
from typing_extensions import Literal, SupportsIndex, TypeAlias, TypeGuard, final
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
@@ -194,8 +194,8 @@ class super:
|
||||
@overload
|
||||
def __init__(self) -> None: ...
|
||||
|
||||
_PositiveInteger = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
|
||||
_NegativeInteger = Literal[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]
|
||||
_PositiveInteger: TypeAlias = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
|
||||
_NegativeInteger: TypeAlias = Literal[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]
|
||||
|
||||
class int:
|
||||
@overload
|
||||
@@ -1263,7 +1263,7 @@ def next(__i: SupportsNext[_T], __default: _VT) -> _T | _VT: ...
|
||||
def oct(__number: int | SupportsIndex) -> str: ...
|
||||
|
||||
_OpenFile = StrOrBytesPath | int
|
||||
_Opener = Callable[[str, int], int]
|
||||
_Opener: TypeAlias = Callable[[str, int], int]
|
||||
|
||||
# Text mode: always returns a TextIOWrapper
|
||||
@overload
|
||||
|
||||
@@ -3,7 +3,7 @@ import sys
|
||||
from _compression import BaseStream
|
||||
from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer
|
||||
from typing import IO, Any, Iterable, Protocol, TextIO, overload
|
||||
from typing_extensions import Literal, SupportsIndex, final
|
||||
from typing_extensions import Literal, SupportsIndex, TypeAlias, final
|
||||
|
||||
__all__ = ["BZ2File", "BZ2Compressor", "BZ2Decompressor", "open", "compress", "decompress"]
|
||||
|
||||
@@ -21,10 +21,10 @@ class _WritableFileobj(Protocol):
|
||||
def compress(data: bytes, compresslevel: int = ...) -> bytes: ...
|
||||
def decompress(data: bytes) -> bytes: ...
|
||||
|
||||
_ReadBinaryMode = Literal["", "r", "rb"]
|
||||
_WriteBinaryMode = Literal["w", "wb", "x", "xb", "a", "ab"]
|
||||
_ReadTextMode = Literal["rt"]
|
||||
_WriteTextMode = Literal["wt", "xt", "at"]
|
||||
_ReadBinaryMode: TypeAlias = Literal["", "r", "rb"]
|
||||
_WriteBinaryMode: TypeAlias = Literal["w", "wb", "x", "xb", "a", "ab"]
|
||||
_ReadTextMode: TypeAlias = Literal["rt"]
|
||||
_WriteTextMode: TypeAlias = Literal["wt", "xt", "at"]
|
||||
|
||||
@overload
|
||||
def open(
|
||||
|
||||
@@ -2,7 +2,7 @@ import sys
|
||||
from _typeshed import Self, StrOrBytesPath
|
||||
from types import CodeType
|
||||
from typing import Any, Callable, TypeVar
|
||||
from typing_extensions import ParamSpec
|
||||
from typing_extensions import ParamSpec, TypeAlias
|
||||
|
||||
__all__ = ["run", "runctx", "Profile"]
|
||||
|
||||
@@ -13,7 +13,7 @@ def runctx(
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_P = ParamSpec("_P")
|
||||
_Label = tuple[str, int, str]
|
||||
_Label: TypeAlias = tuple[str, int, str]
|
||||
|
||||
class Profile:
|
||||
stats: dict[_Label, tuple[int, int, int, int, dict[_Label, tuple[int, int, int, int]]]] # undocumented
|
||||
|
||||
@@ -2,7 +2,7 @@ import datetime
|
||||
import sys
|
||||
from collections.abc import Iterable, Sequence
|
||||
from time import struct_time
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
__all__ = [
|
||||
@@ -66,7 +66,7 @@ else:
|
||||
"weekheader",
|
||||
]
|
||||
|
||||
_LocaleType = tuple[str | None, str | None]
|
||||
_LocaleType: TypeAlias = tuple[str | None, str | None]
|
||||
|
||||
class IllegalMonthError(ValueError):
|
||||
def __init__(self, month: int) -> None: ...
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from _typeshed import StrOrBytesPath
|
||||
from types import FrameType, TracebackType
|
||||
from typing import IO, Any, Callable
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_ExcInfo = tuple[type[BaseException] | None, BaseException | None, TracebackType | None]
|
||||
_ExcInfo: TypeAlias = tuple[type[BaseException] | None, BaseException | None, TracebackType | None]
|
||||
|
||||
__UNDEF__: object # undocumented sentinel
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import sys
|
||||
from typing import SupportsComplex, SupportsFloat
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import SupportsIndex
|
||||
@@ -13,9 +14,9 @@ nanj: complex
|
||||
tau: float
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
_C = SupportsFloat | SupportsComplex | SupportsIndex | complex
|
||||
_C: TypeAlias = SupportsFloat | SupportsComplex | SupportsIndex | complex
|
||||
else:
|
||||
_C = SupportsFloat | SupportsComplex | complex
|
||||
_C: TypeAlias = SupportsFloat | SupportsComplex | complex
|
||||
|
||||
def acos(__z: _C) -> complex: ...
|
||||
def acosh(__z: _C) -> complex: ...
|
||||
|
||||
@@ -3,7 +3,7 @@ import types
|
||||
from _typeshed import Self
|
||||
from abc import abstractmethod
|
||||
from typing import IO, Any, BinaryIO, Callable, Generator, Iterable, Iterator, Protocol, TextIO, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
__all__ = [
|
||||
"register",
|
||||
@@ -83,7 +83,7 @@ class _IncrementalDecoder(Protocol):
|
||||
|
||||
# The type ignore on `encode` and `decode` is to avoid issues with overlapping overloads, for more details, see #300
|
||||
# https://docs.python.org/3/library/codecs.html#binary-transforms
|
||||
_BytesToBytesEncoding = Literal[
|
||||
_BytesToBytesEncoding: TypeAlias = Literal[
|
||||
"base64",
|
||||
"base_64",
|
||||
"base64_codec",
|
||||
@@ -102,7 +102,7 @@ _BytesToBytesEncoding = Literal[
|
||||
"zlib_codec",
|
||||
]
|
||||
# https://docs.python.org/3/library/codecs.html#text-transforms
|
||||
_StrToStrEncoding = Literal["rot13", "rot_13"]
|
||||
_StrToStrEncoding: TypeAlias = Literal["rot13", "rot_13"]
|
||||
|
||||
@overload
|
||||
def encode(obj: bytes, encoding: _BytesToBytesEncoding, errors: str = ...) -> bytes: ...
|
||||
|
||||
@@ -2,7 +2,7 @@ import sys
|
||||
from _typeshed import StrOrBytesPath, StrPath, SupportsWrite
|
||||
from collections.abc import Callable, ItemsView, Iterable, Iterator, Mapping, MutableMapping, Sequence
|
||||
from typing import Any, ClassVar, Pattern, TypeVar, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
__all__ = [
|
||||
"NoSectionError",
|
||||
@@ -29,10 +29,10 @@ __all__ = [
|
||||
]
|
||||
|
||||
# Internal type aliases
|
||||
_section = Mapping[str, str]
|
||||
_parser = MutableMapping[str, _section]
|
||||
_converter = Callable[[str], Any]
|
||||
_converters = dict[str, _converter]
|
||||
_section: TypeAlias = Mapping[str, str]
|
||||
_parser: TypeAlias = MutableMapping[str, _section]
|
||||
_converter: TypeAlias = Callable[[str], Any]
|
||||
_converters: TypeAlias = dict[str, _converter]
|
||||
_T = TypeVar("_T")
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
|
||||
@@ -16,7 +16,7 @@ from typing import ( # noqa: Y027
|
||||
TypeVar,
|
||||
overload,
|
||||
)
|
||||
from typing_extensions import ParamSpec
|
||||
from typing_extensions import ParamSpec, TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
__all__ = [
|
||||
@@ -90,7 +90,7 @@ _T_io = TypeVar("_T_io", bound=IO[str] | None)
|
||||
_F = TypeVar("_F", bound=Callable[..., Any])
|
||||
_P = ParamSpec("_P")
|
||||
|
||||
_ExitFunc = Callable[[type[BaseException] | None, BaseException | None, TracebackType | None], bool | None]
|
||||
_ExitFunc: TypeAlias = Callable[[type[BaseException] | None, BaseException | None, TracebackType | None], bool | None]
|
||||
_CM_EF = TypeVar("_CM_EF", AbstractContextManager[Any], _ExitFunc)
|
||||
|
||||
class ContextDecorator:
|
||||
@@ -189,7 +189,7 @@ class ExitStack(AbstractContextManager[ExitStack]):
|
||||
) -> bool: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
_ExitCoroFunc = Callable[[type[BaseException] | None, BaseException | None, TracebackType | None], Awaitable[bool]]
|
||||
_ExitCoroFunc: TypeAlias = Callable[[type[BaseException] | None, BaseException | None, TracebackType | None], Awaitable[bool]]
|
||||
_ACM_EF = TypeVar("_ACM_EF", AbstractAsyncContextManager[Any], _ExitCoroFunc)
|
||||
|
||||
class AsyncExitStack(AbstractAsyncContextManager[AsyncExitStack]):
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
from typing import Any, Callable, Hashable, SupportsInt, TypeVar, Union
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_Reduce = Union[tuple[Callable[..., _T], tuple[Any, ...]], tuple[Callable[..., _T], tuple[Any, ...], Any | None]]
|
||||
_Reduce: TypeAlias = Union[tuple[Callable[..., _T], tuple[Any, ...]], tuple[Callable[..., _T], tuple[Any, ...], Any | None]]
|
||||
|
||||
__all__ = ["pickle", "constructor", "add_extension", "remove_extension", "clear_extension_cache"]
|
||||
|
||||
@@ -15,5 +16,5 @@ def add_extension(module: Hashable, name: Hashable, code: SupportsInt) -> None:
|
||||
def remove_extension(module: Hashable, name: Hashable, code: int) -> None: ...
|
||||
def clear_extension_cache() -> None: ...
|
||||
|
||||
_DispatchTableType = dict[type, Callable[[Any], str | _Reduce[Any]]] # imported by multiprocessing.reduction
|
||||
_DispatchTableType: TypeAlias = dict[type, Callable[[Any], str | _Reduce[Any]]] # imported by multiprocessing.reduction
|
||||
dispatch_table: _DispatchTableType # undocumented
|
||||
|
||||
@@ -2,6 +2,7 @@ import sys
|
||||
from _typeshed import ReadableBuffer, Self, WriteableBuffer
|
||||
from abc import abstractmethod
|
||||
from typing import Any, Callable, ClassVar, Generic, Iterable, Iterator, Mapping, Sequence, TypeVar, Union as _UnionT, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
@@ -84,8 +85,8 @@ class _CData(metaclass=_CDataMeta):
|
||||
class _CanCastTo(_CData): ...
|
||||
class _PointerLike(_CanCastTo): ...
|
||||
|
||||
_ECT = Callable[[type[_CData] | None, _FuncPointer, tuple[_CData, ...]], _CData]
|
||||
_PF = _UnionT[tuple[int], tuple[int, str], tuple[int, str, Any]]
|
||||
_ECT: TypeAlias = Callable[[type[_CData] | None, _FuncPointer, tuple[_CData, ...]], _CData]
|
||||
_PF: TypeAlias = _UnionT[tuple[int], tuple[int, str], tuple[int, str, Any]]
|
||||
|
||||
class _FuncPointer(_PointerLike, _CData):
|
||||
restype: type[_CData] | Callable[[int], Any] | None
|
||||
@@ -121,12 +122,12 @@ class _CArgObject: ...
|
||||
|
||||
# Any type that can be implicitly converted to c_void_p when passed as a C function argument.
|
||||
# (bytes is not included here, see below.)
|
||||
_CVoidPLike = _PointerLike | Array[Any] | _CArgObject | int
|
||||
_CVoidPLike: TypeAlias = _PointerLike | Array[Any] | _CArgObject | int
|
||||
# Same as above, but including types known to be read-only (i. e. bytes).
|
||||
# This distinction is not strictly necessary (ctypes doesn't differentiate between const
|
||||
# and non-const pointers), but it catches errors like memmove(b'foo', buf, 4)
|
||||
# when memmove(buf, b'foo', 4) was intended.
|
||||
_CVoidConstPLike = _CVoidPLike | bytes
|
||||
_CVoidConstPLike: TypeAlias = _CVoidPLike | bytes
|
||||
|
||||
def addressof(obj: _CData) -> int: ...
|
||||
def alignment(obj_or_type: _CData | type[_CData]) -> int: ...
|
||||
|
||||
@@ -20,6 +20,7 @@ from ctypes import (
|
||||
c_wchar_p,
|
||||
pointer,
|
||||
)
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
BYTE = c_byte
|
||||
WORD = c_ushort
|
||||
@@ -182,53 +183,53 @@ class WIN32_FIND_DATAW(Structure):
|
||||
|
||||
# These pointer type definitions use pointer[...] instead of POINTER(...), to allow them
|
||||
# to be used in type annotations.
|
||||
PBOOL = pointer[BOOL]
|
||||
LPBOOL = pointer[BOOL]
|
||||
PBOOLEAN = pointer[BOOLEAN]
|
||||
PBYTE = pointer[BYTE]
|
||||
LPBYTE = pointer[BYTE]
|
||||
PCHAR = pointer[CHAR]
|
||||
LPCOLORREF = pointer[COLORREF]
|
||||
PDWORD = pointer[DWORD]
|
||||
LPDWORD = pointer[DWORD]
|
||||
PFILETIME = pointer[FILETIME]
|
||||
LPFILETIME = pointer[FILETIME]
|
||||
PFLOAT = pointer[FLOAT]
|
||||
PHANDLE = pointer[HANDLE]
|
||||
LPHANDLE = pointer[HANDLE]
|
||||
PHKEY = pointer[HKEY]
|
||||
LPHKL = pointer[HKL]
|
||||
PINT = pointer[INT]
|
||||
LPINT = pointer[INT]
|
||||
PLARGE_INTEGER = pointer[LARGE_INTEGER]
|
||||
PLCID = pointer[LCID]
|
||||
PLONG = pointer[LONG]
|
||||
LPLONG = pointer[LONG]
|
||||
PMSG = pointer[MSG]
|
||||
LPMSG = pointer[MSG]
|
||||
PPOINT = pointer[POINT]
|
||||
LPPOINT = pointer[POINT]
|
||||
PPOINTL = pointer[POINTL]
|
||||
PRECT = pointer[RECT]
|
||||
LPRECT = pointer[RECT]
|
||||
PRECTL = pointer[RECTL]
|
||||
LPRECTL = pointer[RECTL]
|
||||
LPSC_HANDLE = pointer[SC_HANDLE]
|
||||
PSHORT = pointer[SHORT]
|
||||
PSIZE = pointer[SIZE]
|
||||
LPSIZE = pointer[SIZE]
|
||||
PSIZEL = pointer[SIZEL]
|
||||
LPSIZEL = pointer[SIZEL]
|
||||
PSMALL_RECT = pointer[SMALL_RECT]
|
||||
PUINT = pointer[UINT]
|
||||
LPUINT = pointer[UINT]
|
||||
PULARGE_INTEGER = pointer[ULARGE_INTEGER]
|
||||
PULONG = pointer[ULONG]
|
||||
PUSHORT = pointer[USHORT]
|
||||
PWCHAR = pointer[WCHAR]
|
||||
PWIN32_FIND_DATAA = pointer[WIN32_FIND_DATAA]
|
||||
LPWIN32_FIND_DATAA = pointer[WIN32_FIND_DATAA]
|
||||
PWIN32_FIND_DATAW = pointer[WIN32_FIND_DATAW]
|
||||
LPWIN32_FIND_DATAW = pointer[WIN32_FIND_DATAW]
|
||||
PWORD = pointer[WORD]
|
||||
LPWORD = pointer[WORD]
|
||||
PBOOL: TypeAlias = pointer[BOOL]
|
||||
LPBOOL: TypeAlias = pointer[BOOL]
|
||||
PBOOLEAN: TypeAlias = pointer[BOOLEAN]
|
||||
PBYTE: TypeAlias = pointer[BYTE]
|
||||
LPBYTE: TypeAlias = pointer[BYTE]
|
||||
PCHAR: TypeAlias = pointer[CHAR]
|
||||
LPCOLORREF: TypeAlias = pointer[COLORREF]
|
||||
PDWORD: TypeAlias = pointer[DWORD]
|
||||
LPDWORD: TypeAlias = pointer[DWORD]
|
||||
PFILETIME: TypeAlias = pointer[FILETIME]
|
||||
LPFILETIME: TypeAlias = pointer[FILETIME]
|
||||
PFLOAT: TypeAlias = pointer[FLOAT]
|
||||
PHANDLE: TypeAlias = pointer[HANDLE]
|
||||
LPHANDLE: TypeAlias = pointer[HANDLE]
|
||||
PHKEY: TypeAlias = pointer[HKEY]
|
||||
LPHKL: TypeAlias = pointer[HKL]
|
||||
PINT: TypeAlias = pointer[INT]
|
||||
LPINT: TypeAlias = pointer[INT]
|
||||
PLARGE_INTEGER: TypeAlias = pointer[LARGE_INTEGER]
|
||||
PLCID: TypeAlias = pointer[LCID]
|
||||
PLONG: TypeAlias = pointer[LONG]
|
||||
LPLONG: TypeAlias = pointer[LONG]
|
||||
PMSG: TypeAlias = pointer[MSG]
|
||||
LPMSG: TypeAlias = pointer[MSG]
|
||||
PPOINT: TypeAlias = pointer[POINT]
|
||||
LPPOINT: TypeAlias = pointer[POINT]
|
||||
PPOINTL: TypeAlias = pointer[POINTL]
|
||||
PRECT: TypeAlias = pointer[RECT]
|
||||
LPRECT: TypeAlias = pointer[RECT]
|
||||
PRECTL: TypeAlias = pointer[RECTL]
|
||||
LPRECTL: TypeAlias = pointer[RECTL]
|
||||
LPSC_HANDLE: TypeAlias = pointer[SC_HANDLE]
|
||||
PSHORT: TypeAlias = pointer[SHORT]
|
||||
PSIZE: TypeAlias = pointer[SIZE]
|
||||
LPSIZE: TypeAlias = pointer[SIZE]
|
||||
PSIZEL: TypeAlias = pointer[SIZEL]
|
||||
LPSIZEL: TypeAlias = pointer[SIZEL]
|
||||
PSMALL_RECT: TypeAlias = pointer[SMALL_RECT]
|
||||
PUINT: TypeAlias = pointer[UINT]
|
||||
LPUINT: TypeAlias = pointer[UINT]
|
||||
PULARGE_INTEGER: TypeAlias = pointer[ULARGE_INTEGER]
|
||||
PULONG: TypeAlias = pointer[ULONG]
|
||||
PUSHORT: TypeAlias = pointer[USHORT]
|
||||
PWCHAR: TypeAlias = pointer[WCHAR]
|
||||
PWIN32_FIND_DATAA: TypeAlias = pointer[WIN32_FIND_DATAA]
|
||||
LPWIN32_FIND_DATAA: TypeAlias = pointer[WIN32_FIND_DATAA]
|
||||
PWIN32_FIND_DATAW: TypeAlias = pointer[WIN32_FIND_DATAW]
|
||||
LPWIN32_FIND_DATAW: TypeAlias = pointer[WIN32_FIND_DATAW]
|
||||
PWORD: TypeAlias = pointer[WORD]
|
||||
LPWORD: TypeAlias = pointer[WORD]
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
from _typeshed import Self
|
||||
from types import TracebackType
|
||||
from typing import Iterator, MutableMapping
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
__all__ = ["open", "whichdb", "error"]
|
||||
|
||||
_KeyType = str | bytes
|
||||
_ValueType = str | bytes
|
||||
_TFlags = Literal[
|
||||
_KeyType: TypeAlias = str | bytes
|
||||
_ValueType: TypeAlias = str | bytes
|
||||
_TFlags: TypeAlias = Literal[
|
||||
"r",
|
||||
"w",
|
||||
"c",
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
from _typeshed import Self
|
||||
from types import TracebackType
|
||||
from typing import Iterator, MutableMapping
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = ["error", "open"]
|
||||
|
||||
_KeyType = str | bytes
|
||||
_ValueType = str | bytes
|
||||
_KeyType: TypeAlias = str | bytes
|
||||
_ValueType: TypeAlias = str | bytes
|
||||
|
||||
error = OSError
|
||||
|
||||
|
||||
@@ -2,11 +2,12 @@ import sys
|
||||
from _typeshed import Self
|
||||
from types import TracebackType
|
||||
from typing import TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.platform != "win32":
|
||||
_T = TypeVar("_T")
|
||||
_KeyType = str | bytes
|
||||
_ValueType = str | bytes
|
||||
_KeyType: TypeAlias = str | bytes
|
||||
_ValueType: TypeAlias = str | bytes
|
||||
|
||||
open_flags: str
|
||||
|
||||
|
||||
@@ -2,11 +2,12 @@ import sys
|
||||
from _typeshed import Self
|
||||
from types import TracebackType
|
||||
from typing import TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.platform != "win32":
|
||||
_T = TypeVar("_T")
|
||||
_KeyType = str | bytes
|
||||
_ValueType = str | bytes
|
||||
_KeyType: TypeAlias = str | bytes
|
||||
_ValueType: TypeAlias = str | bytes
|
||||
|
||||
class error(OSError): ...
|
||||
library: str
|
||||
|
||||
@@ -3,10 +3,11 @@ import sys
|
||||
from _typeshed import Self
|
||||
from types import TracebackType
|
||||
from typing import Any, Container, NamedTuple, Sequence, Union, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_Decimal = Decimal | int
|
||||
_DecimalNew = Union[Decimal, float, str, tuple[int, Sequence[int], int]]
|
||||
_ComparableNum = Decimal | float | numbers.Rational
|
||||
_Decimal: TypeAlias = Decimal | int
|
||||
_DecimalNew: TypeAlias = Union[Decimal, float, str, tuple[int, Sequence[int], int]]
|
||||
_ComparableNum: TypeAlias = Decimal | float | numbers.Rational
|
||||
|
||||
__libmpdec_version__: str
|
||||
|
||||
@@ -159,7 +160,7 @@ class _ContextManager:
|
||||
def __enter__(self) -> Context: ...
|
||||
def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
|
||||
|
||||
_TrapType = type[DecimalException]
|
||||
_TrapType: TypeAlias = type[DecimalException]
|
||||
|
||||
class Context:
|
||||
prec: int
|
||||
|
||||
@@ -3,6 +3,7 @@ import types
|
||||
from _typeshed import Self
|
||||
from opcode import * # `dis` re-exports it as a part of public API
|
||||
from typing import IO, Any, Callable, Iterator, NamedTuple
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = [
|
||||
"code_info",
|
||||
@@ -34,8 +35,8 @@ __all__ = [
|
||||
|
||||
# Strictly this should not have to include Callable, but mypy doesn't use FunctionType
|
||||
# for functions (python/mypy#3171)
|
||||
_HaveCodeType = types.MethodType | types.FunctionType | types.CodeType | type | Callable[..., Any]
|
||||
_HaveCodeOrStringType = _HaveCodeType | str | bytes
|
||||
_HaveCodeType: TypeAlias = types.MethodType | types.FunctionType | types.CodeType | type | Callable[..., Any]
|
||||
_HaveCodeOrStringType: TypeAlias = _HaveCodeType | str | bytes
|
||||
|
||||
class Instruction(NamedTuple):
|
||||
opname: str
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from typing import Any, Callable, Union
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_Macro = Union[tuple[str], tuple[str, str | None]]
|
||||
_Macro: TypeAlias = Union[tuple[str], tuple[str, str | None]]
|
||||
|
||||
def gen_lib_options(
|
||||
compiler: CCompiler, library_dirs: list[str], runtime_library_dirs: list[str], libraries: list[str]
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
from typing import Any, Iterable, Mapping, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_Option = tuple[str, str | None, str]
|
||||
_GR = tuple[list[str], OptionDummy]
|
||||
_Option: TypeAlias = tuple[str, str | None, str]
|
||||
_GR: TypeAlias = tuple[list[str], OptionDummy]
|
||||
|
||||
def fancy_getopt(
|
||||
options: list[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: list[str] | None
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import types
|
||||
import unittest
|
||||
from typing import Any, Callable, NamedTuple
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = [
|
||||
"register_optionflag",
|
||||
@@ -123,8 +124,8 @@ class DocTestFinder:
|
||||
extraglobs: dict[str, Any] | None = ...,
|
||||
) -> list[DocTest]: ...
|
||||
|
||||
_Out = Callable[[str], Any]
|
||||
_ExcInfo = tuple[type[BaseException], BaseException, types.TracebackType]
|
||||
_Out: TypeAlias = Callable[[str], Any]
|
||||
_ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, types.TracebackType]
|
||||
|
||||
class DocTestRunner:
|
||||
DIVIDER: str
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
from email.message import Message
|
||||
from email.policy import Policy
|
||||
from typing import IO, Callable, TypeVar, Union
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
# Definitions imported by multiple submodules in typeshed
|
||||
_MessageT = TypeVar("_MessageT", bound=Message) # noqa: Y018
|
||||
_ParamType = Union[str, tuple[str | None, str | None, str]]
|
||||
_ParamsType = Union[str, None, tuple[str, str | None, str]]
|
||||
_ParamType: TypeAlias = Union[str, tuple[str | None, str | None, str]]
|
||||
_ParamsType: TypeAlias = Union[str, None, tuple[str, str | None, str]]
|
||||
|
||||
def message_from_string(s: str, _class: Callable[[], Message] = ..., *, policy: Policy = ...) -> Message: ...
|
||||
def message_from_bytes(s: bytes, _class: Callable[[], Message] = ..., *, policy: Policy = ...) -> Message: ...
|
||||
|
||||
@@ -4,13 +4,14 @@ from email.contentmanager import ContentManager
|
||||
from email.errors import MessageDefect
|
||||
from email.policy import Policy
|
||||
from typing import Any, Generator, Iterator, Sequence, TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = ["Message", "EmailMessage"]
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
_PayloadType = list[Message] | str | bytes
|
||||
_CharsetType = Charset | str | None
|
||||
_PayloadType: TypeAlias = list[Message] | str | bytes
|
||||
_CharsetType: TypeAlias = Charset | str | None
|
||||
_HeaderType = Any
|
||||
|
||||
class Message:
|
||||
|
||||
@@ -3,11 +3,12 @@ from email import _MessageT
|
||||
from email.message import Message
|
||||
from email.policy import Policy
|
||||
from typing import BinaryIO, Callable, TextIO
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = ["Parser", "HeaderParser", "BytesParser", "BytesHeaderParser", "FeedParser", "BytesFeedParser"]
|
||||
|
||||
FeedParser = email.feedparser.FeedParser[_MessageT]
|
||||
BytesFeedParser = email.feedparser.BytesFeedParser[_MessageT]
|
||||
FeedParser: TypeAlias = email.feedparser.FeedParser[_MessageT]
|
||||
BytesFeedParser: TypeAlias = email.feedparser.BytesFeedParser[_MessageT]
|
||||
|
||||
class Parser:
|
||||
def __init__(self, _class: Callable[[], Message] | None = ..., *, policy: Policy = ...) -> None: ...
|
||||
|
||||
@@ -3,6 +3,7 @@ import sys
|
||||
from email import _ParamType
|
||||
from email.charset import Charset
|
||||
from typing import overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = [
|
||||
"collapse_rfc2231_value",
|
||||
@@ -22,7 +23,7 @@ __all__ = [
|
||||
"unquote",
|
||||
]
|
||||
|
||||
_PDTZ = tuple[int, int, int, int, int, int, int, int, int, int | None]
|
||||
_PDTZ: TypeAlias = tuple[int, int, int, int, int, int, int, int, int, int | None]
|
||||
|
||||
def quote(str: str) -> str: ...
|
||||
def unquote(str: str) -> str: ...
|
||||
|
||||
@@ -5,7 +5,7 @@ from abc import ABCMeta
|
||||
from builtins import property as _builtins_property
|
||||
from collections.abc import Iterable, Iterator, Mapping
|
||||
from typing import Any, TypeVar, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
__all__ = [
|
||||
@@ -52,7 +52,7 @@ _EnumerationT = TypeVar("_EnumerationT", bound=type[Enum])
|
||||
# <enum 'Foo'>
|
||||
# >>> Enum('Foo', names={'RED': 1, 'YELLOW': 2})
|
||||
# <enum 'Foo'>
|
||||
_EnumNames = str | Iterable[str] | Iterable[Iterable[str | Any]] | Mapping[str, Any]
|
||||
_EnumNames: TypeAlias = str | Iterable[str] | Iterable[Iterable[str | Any]] | Mapping[str, Any]
|
||||
|
||||
class _EnumDict(dict[str, Any]):
|
||||
def __init__(self) -> None: ...
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from typing import IO, Any, Iterable
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
AS_IS: None
|
||||
_FontType = tuple[str, bool, bool, bool]
|
||||
_StylesType = tuple[Any, ...]
|
||||
_FontType: TypeAlias = tuple[str, bool, bool, bool]
|
||||
_StylesType: TypeAlias = tuple[Any, ...]
|
||||
|
||||
class NullFormatter:
|
||||
writer: NullWriter | None
|
||||
|
||||
@@ -3,9 +3,9 @@ from _typeshed import Self
|
||||
from decimal import Decimal
|
||||
from numbers import Integral, Rational, Real
|
||||
from typing import Any, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
_ComparableNum = int | float | Decimal | Real
|
||||
_ComparableNum: TypeAlias = int | float | Decimal | Real
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
__all__ = ["Fraction"]
|
||||
|
||||
@@ -2,7 +2,7 @@ import sys
|
||||
import types
|
||||
from _typeshed import Self, SupportsAllComparisons, SupportsItems
|
||||
from typing import Any, Callable, Generic, Hashable, Iterable, NamedTuple, Sequence, Sized, TypeVar, overload
|
||||
from typing_extensions import Literal, final
|
||||
from typing_extensions import Literal, TypeAlias, final
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
@@ -54,7 +54,7 @@ else:
|
||||
"singledispatch",
|
||||
]
|
||||
|
||||
_AnyCallable = Callable[..., Any]
|
||||
_AnyCallable: TypeAlias = Callable[..., Any]
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_S = TypeVar("_S")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import sys
|
||||
from typing import Any, Callable
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
DEBUG_COLLECTABLE: Literal[2]
|
||||
DEBUG_LEAK: Literal[38]
|
||||
@@ -8,7 +8,7 @@ DEBUG_SAVEALL: Literal[32]
|
||||
DEBUG_STATS: Literal[1]
|
||||
DEBUG_UNCOLLECTABLE: Literal[4]
|
||||
|
||||
_CallbackType = Callable[[Literal["start", "stop"], dict[str, int]], object]
|
||||
_CallbackType: TypeAlias = Callable[[Literal["start", "stop"], dict[str, int]], object]
|
||||
|
||||
callbacks: list[_CallbackType]
|
||||
garbage: list[Any]
|
||||
|
||||
@@ -4,16 +4,16 @@ import zlib
|
||||
from _typeshed import ReadableBuffer, StrOrBytesPath
|
||||
from io import FileIO
|
||||
from typing import Any, Protocol, TextIO, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
__all__ = ["BadGzipFile", "GzipFile", "open", "compress", "decompress"]
|
||||
else:
|
||||
__all__ = ["GzipFile", "open", "compress", "decompress"]
|
||||
|
||||
_ReadBinaryMode = Literal["r", "rb"]
|
||||
_WriteBinaryMode = Literal["a", "ab", "w", "wb", "x", "xb"]
|
||||
_OpenTextMode = Literal["rt", "at", "wt", "xt"]
|
||||
_ReadBinaryMode: TypeAlias = Literal["r", "rb"]
|
||||
_WriteBinaryMode: TypeAlias = Literal["a", "ab", "w", "wb", "x", "xb"]
|
||||
_OpenTextMode: TypeAlias = Literal["rt", "at", "wt", "xt"]
|
||||
|
||||
READ: Literal[1]
|
||||
WRITE: Literal[2]
|
||||
|
||||
@@ -2,10 +2,11 @@ import sys
|
||||
from _typeshed import ReadableBuffer
|
||||
from types import ModuleType
|
||||
from typing import Any, AnyStr, Callable, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
# TODO more precise type for object of hashlib
|
||||
_Hash = Any
|
||||
_DigestMod = str | Callable[[], _Hash] | ModuleType
|
||||
_Hash: TypeAlias = Any
|
||||
_DigestMod: TypeAlias = str | Callable[[], _Hash] | ModuleType
|
||||
|
||||
trans_5C: bytes
|
||||
trans_36: bytes
|
||||
|
||||
@@ -6,6 +6,7 @@ import types
|
||||
from _typeshed import Self, WriteableBuffer
|
||||
from socket import socket
|
||||
from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, Mapping, Protocol, TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = [
|
||||
"HTTPResponse",
|
||||
@@ -29,7 +30,7 @@ __all__ = [
|
||||
"HTTPSConnection",
|
||||
]
|
||||
|
||||
_DataType = bytes | IO[Any] | Iterable[bytes] | str
|
||||
_DataType: TypeAlias = bytes | IO[Any] | Iterable[bytes] | str
|
||||
_T = TypeVar("_T")
|
||||
|
||||
HTTP_PORT: int
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import sys
|
||||
from typing import Any, Generic, Iterable, Mapping, TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
__all__ = ["CookieError", "BaseCookie", "SimpleCookie"]
|
||||
|
||||
_DataType = str | Mapping[str, str | Morsel[Any]]
|
||||
_DataType: TypeAlias = str | Mapping[str, str | Morsel[Any]]
|
||||
_T = TypeVar("_T")
|
||||
|
||||
@overload
|
||||
|
||||
@@ -5,18 +5,19 @@ from _typeshed import Self
|
||||
from socket import socket as _socket
|
||||
from ssl import SSLContext, SSLSocket
|
||||
from types import TracebackType
|
||||
from typing import IO, Any, Callable, Pattern
|
||||
from typing_extensions import Literal
|
||||
from typing import IO, Any, Callable, Pattern, TypeVar
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
__all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple", "Int2AP", "ParseFlags", "Time2Internaldate", "IMAP4_SSL"]
|
||||
|
||||
# TODO: Commands should use their actual return types, not this type alias.
|
||||
# E.g. Tuple[Literal["OK"], List[bytes]]
|
||||
_CommandResults = tuple[str, list[Any]]
|
||||
_CommandResults: TypeAlias = tuple[str, list[Any]]
|
||||
|
||||
_AnyResponseData = list[None] | list[bytes | tuple[bytes, bytes]]
|
||||
_AnyResponseData: TypeAlias = list[None] | list[bytes | tuple[bytes, bytes]]
|
||||
|
||||
_list = list # conflicts with a method named "list"
|
||||
_T = TypeVar("_T")
|
||||
_list: TypeAlias = list[_T] # conflicts with a method named "list"
|
||||
|
||||
class IMAP4:
|
||||
error: type[Exception]
|
||||
|
||||
@@ -13,9 +13,9 @@ from abc import ABCMeta, abstractmethod
|
||||
from importlib.machinery import ModuleSpec
|
||||
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
|
||||
from typing import IO, Any, BinaryIO, Iterator, Mapping, NoReturn, Protocol, Sequence, overload, runtime_checkable
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
_Path = bytes | str
|
||||
_Path: TypeAlias = bytes | str
|
||||
|
||||
class Finder(metaclass=ABCMeta): ...
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ from contextlib import AbstractContextManager
|
||||
from pathlib import Path
|
||||
from types import ModuleType
|
||||
from typing import Any, BinaryIO, Iterator, TextIO
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
__all__ = [
|
||||
@@ -37,8 +38,8 @@ elif sys.version_info >= (3, 9):
|
||||
else:
|
||||
__all__ = ["Package", "Resource", "contents", "is_resource", "open_binary", "open_text", "path", "read_binary", "read_text"]
|
||||
|
||||
Package = str | ModuleType
|
||||
Resource = str | os.PathLike[Any]
|
||||
Package: TypeAlias = str | ModuleType
|
||||
Resource: TypeAlias = str | os.PathLike[Any]
|
||||
|
||||
def open_binary(package: Package, resource: Resource) -> BinaryIO: ...
|
||||
def open_text(package: Package, resource: Resource, encoding: str = ..., errors: str = ...) -> TextIO: ...
|
||||
|
||||
@@ -19,6 +19,7 @@ from types import (
|
||||
ModuleType,
|
||||
TracebackType,
|
||||
)
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from types import (
|
||||
@@ -165,8 +166,8 @@ TPFLAGS_IS_ABSTRACT: Literal[1048576]
|
||||
|
||||
modulesbyfile: dict[str, Any]
|
||||
|
||||
_GetMembersPredicate = Callable[[Any], bool]
|
||||
_GetMembersReturn = list[tuple[str, Any]]
|
||||
_GetMembersPredicate: TypeAlias = Callable[[Any], bool]
|
||||
_GetMembersReturn: TypeAlias = list[tuple[str, Any]]
|
||||
|
||||
def getmembers(object: object, predicate: _GetMembersPredicate | None = ...) -> _GetMembersReturn: ...
|
||||
|
||||
@@ -242,7 +243,9 @@ def isdatadescriptor(object: object) -> TypeGuard[_SupportsSet[Any, Any] | _Supp
|
||||
#
|
||||
# Retrieving source code
|
||||
#
|
||||
_SourceObjectType = Union[ModuleType, type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType, Callable[..., Any]]
|
||||
_SourceObjectType: TypeAlias = Union[
|
||||
ModuleType, type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType, Callable[..., Any]
|
||||
]
|
||||
|
||||
def findsource(object: _SourceObjectType) -> tuple[list[str], int]: ...
|
||||
def getabsfile(object: _SourceObjectType, _filename: str | None = ...) -> str: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
from _typeshed import Self
|
||||
from typing import Any, Container, Generic, Iterable, Iterator, SupportsInt, TypeVar, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
# Undocumented length constants
|
||||
IPV4LENGTH: Literal[32]
|
||||
@@ -10,8 +10,8 @@ IPV6LENGTH: Literal[128]
|
||||
_A = TypeVar("_A", IPv4Address, IPv6Address)
|
||||
_N = TypeVar("_N", IPv4Network, IPv6Network)
|
||||
|
||||
_RawIPAddress = int | str | bytes | IPv4Address | IPv6Address
|
||||
_RawNetworkPart = IPv4Network | IPv6Network | IPv4Interface | IPv6Interface
|
||||
_RawIPAddress: TypeAlias = int | str | bytes | IPv4Address | IPv6Address
|
||||
_RawNetworkPart: TypeAlias = IPv4Network | IPv6Network | IPv4Interface | IPv6Interface
|
||||
|
||||
def ip_address(address: _RawIPAddress) -> IPv4Address | IPv6Address: ...
|
||||
def ip_network(address: _RawIPAddress | _RawNetworkPart, strict: bool = ...) -> IPv4Network | IPv6Network: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
from _typeshed import Self, _T_co
|
||||
from typing import Any, Callable, Generic, Iterable, Iterator, SupportsComplex, SupportsFloat, SupportsInt, TypeVar, overload
|
||||
from typing_extensions import Literal, SupportsIndex
|
||||
from typing_extensions import Literal, SupportsIndex, TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
@@ -9,9 +9,9 @@ if sys.version_info >= (3, 9):
|
||||
_T = TypeVar("_T")
|
||||
_S = TypeVar("_S")
|
||||
_N = TypeVar("_N", int, float, SupportsFloat, SupportsInt, SupportsIndex, SupportsComplex)
|
||||
_Step = int | float | SupportsFloat | SupportsInt | SupportsIndex | SupportsComplex
|
||||
_Step: TypeAlias = int | float | SupportsFloat | SupportsInt | SupportsIndex | SupportsComplex
|
||||
|
||||
Predicate = Callable[[_T], object]
|
||||
Predicate: TypeAlias = Callable[[_T], object]
|
||||
|
||||
# Technically count can take anything that implements a number protocol and has an add method
|
||||
# but we can't enforce the add method
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from _typeshed import Self, StrPath
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_Label = tuple[int, str | None]
|
||||
_DFA = list[list[tuple[int, int]]]
|
||||
_DFAS = tuple[_DFA, dict[int, int]]
|
||||
_Label: TypeAlias = tuple[int, str | None]
|
||||
_DFA: TypeAlias = list[list[tuple[int, int]]]
|
||||
_DFAS: TypeAlias = tuple[_DFA, dict[int, int]]
|
||||
|
||||
class Grammar:
|
||||
symbol2number: dict[str, int]
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from lib2to3.pgen2.grammar import _DFAS, Grammar
|
||||
from lib2to3.pytree import _NL, _Convert, _RawNode
|
||||
from typing import Any, Sequence
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_Context = Sequence[Any]
|
||||
_Context: TypeAlias = Sequence[Any]
|
||||
|
||||
class ParseError(Exception):
|
||||
msg: str
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import sys
|
||||
from lib2to3.pgen2.token import *
|
||||
from typing import Callable, Iterable, Iterator
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
__all__ = [
|
||||
@@ -146,9 +147,9 @@ else:
|
||||
"untokenize",
|
||||
]
|
||||
|
||||
_Coord = tuple[int, int]
|
||||
_TokenEater = Callable[[int, str, _Coord, _Coord, str], None]
|
||||
_TokenInfo = tuple[int, str, _Coord, _Coord, str]
|
||||
_Coord: TypeAlias = tuple[int, int]
|
||||
_TokenEater: TypeAlias = Callable[[int, str, _Coord, _Coord, str], None]
|
||||
_TokenInfo: TypeAlias = tuple[int, str, _Coord, _Coord, str]
|
||||
|
||||
class TokenError(Exception): ...
|
||||
class StopTokenizing(Exception): ...
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
from _typeshed import Self
|
||||
from lib2to3.pgen2.grammar import Grammar
|
||||
from typing import Any, Callable, Iterator
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_NL = Node | Leaf
|
||||
_Context = tuple[str, int, int]
|
||||
_Results = dict[str, _NL]
|
||||
_RawNode = tuple[int, str, _Context, list[_NL] | None]
|
||||
_Convert = Callable[[Grammar, _RawNode], Any]
|
||||
_NL: TypeAlias = Node | Leaf
|
||||
_Context: TypeAlias = tuple[str, int, int]
|
||||
_Results: TypeAlias = dict[str, _NL]
|
||||
_RawNode: TypeAlias = tuple[int, str, _Context, list[_NL] | None]
|
||||
_Convert: TypeAlias = Callable[[Grammar, _RawNode], Any]
|
||||
|
||||
HUGE: int
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import sys
|
||||
from typing import Any, Protocol
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
__all__ = ["getline", "clearcache", "checkcache", "lazycache"]
|
||||
else:
|
||||
__all__ = ["getline", "clearcache", "checkcache"]
|
||||
|
||||
_ModuleGlobals = dict[str, Any]
|
||||
_ModuleMetadata = tuple[int, float | None, list[str], str]
|
||||
_ModuleGlobals: TypeAlias = dict[str, Any]
|
||||
_ModuleMetadata: TypeAlias = tuple[int, float | None, list[str], str]
|
||||
|
||||
class _SourceLoader(Protocol):
|
||||
def __call__(self) -> str | None: ...
|
||||
|
||||
@@ -7,7 +7,7 @@ from string import Template
|
||||
from time import struct_time
|
||||
from types import FrameType, TracebackType
|
||||
from typing import Any, ClassVar, Generic, Pattern, TextIO, TypeVar, Union, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
__all__ = [
|
||||
"BASIC_FORMAT",
|
||||
@@ -54,12 +54,12 @@ __all__ = [
|
||||
"raiseExceptions",
|
||||
]
|
||||
|
||||
_SysExcInfoType = Union[tuple[type[BaseException], BaseException, TracebackType | None], tuple[None, None, None]]
|
||||
_ExcInfoType = None | bool | _SysExcInfoType | BaseException
|
||||
_ArgsType = tuple[object, ...] | Mapping[str, object]
|
||||
_FilterType = Filter | Callable[[LogRecord], int]
|
||||
_Level = int | str
|
||||
_FormatStyle = Literal["%", "{", "$"]
|
||||
_SysExcInfoType: TypeAlias = Union[tuple[type[BaseException], BaseException, TracebackType | None], tuple[None, None, None]]
|
||||
_ExcInfoType: TypeAlias = None | bool | _SysExcInfoType | BaseException
|
||||
_ArgsType: TypeAlias = tuple[object, ...] | Mapping[str, object]
|
||||
_FilterType: TypeAlias = Filter | Callable[[LogRecord], int]
|
||||
_Level: TypeAlias = int | str
|
||||
_FormatStyle: TypeAlias = Literal["%", "{", "$"]
|
||||
|
||||
raiseExceptions: bool
|
||||
logThreads: bool
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import io
|
||||
from _typeshed import ReadableBuffer, Self, StrOrBytesPath
|
||||
from typing import IO, Any, Mapping, Sequence, TextIO, overload
|
||||
from typing_extensions import Literal, final
|
||||
from typing_extensions import Literal, TypeAlias, final
|
||||
|
||||
__all__ = [
|
||||
"CHECK_NONE",
|
||||
@@ -42,12 +42,12 @@ __all__ = [
|
||||
"is_check_supported",
|
||||
]
|
||||
|
||||
_OpenBinaryWritingMode = Literal["w", "wb", "x", "xb", "a", "ab"]
|
||||
_OpenTextWritingMode = Literal["wt", "xt", "at"]
|
||||
_OpenBinaryWritingMode: TypeAlias = Literal["w", "wb", "x", "xb", "a", "ab"]
|
||||
_OpenTextWritingMode: TypeAlias = Literal["wt", "xt", "at"]
|
||||
|
||||
_PathOrFile = StrOrBytesPath | IO[bytes]
|
||||
_PathOrFile: TypeAlias = StrOrBytesPath | IO[bytes]
|
||||
|
||||
_FilterChain = Sequence[Mapping[str, Any]]
|
||||
_FilterChain: TypeAlias = Sequence[Mapping[str, Any]]
|
||||
|
||||
FORMAT_AUTO: Literal[0]
|
||||
FORMAT_XZ: Literal[1]
|
||||
|
||||
@@ -4,7 +4,7 @@ from _typeshed import Self, StrOrBytesPath
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from types import TracebackType
|
||||
from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Mapping, Protocol, Sequence, TypeVar, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
@@ -31,7 +31,7 @@ __all__ = [
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_MessageT = TypeVar("_MessageT", bound=Message)
|
||||
_MessageData = email.message.Message | bytes | str | IO[str] | IO[bytes]
|
||||
_MessageData: TypeAlias = email.message.Message | bytes | str | IO[str] | IO[bytes]
|
||||
|
||||
class _HasIteritems(Protocol):
|
||||
def iteritems(self) -> Iterator[tuple[str, _MessageData]]: ...
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from typing import Mapping, Sequence
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_Cap = dict[str, str | int]
|
||||
_Cap: TypeAlias = dict[str, str | int]
|
||||
|
||||
__all__ = ["getcaps", "findmatch"]
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import sys
|
||||
from _typeshed import SupportsTrunc
|
||||
from typing import Iterable, SupportsFloat, overload
|
||||
from typing_extensions import SupportsIndex
|
||||
from typing_extensions import SupportsIndex, TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
_SupportsFloatOrIndex = SupportsFloat | SupportsIndex
|
||||
_SupportsFloatOrIndex: TypeAlias = SupportsFloat | SupportsIndex
|
||||
else:
|
||||
_SupportsFloatOrIndex = SupportsFloat
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import sys
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.platform == "win32":
|
||||
|
||||
_SequenceType = list[tuple[str, str | None, int]]
|
||||
_SequenceType: TypeAlias = list[tuple[str, str | None, int]]
|
||||
|
||||
AdminExecuteSequence: _SequenceType
|
||||
AdminUISequence: _SequenceType
|
||||
|
||||
@@ -20,8 +20,8 @@ from multiprocessing.process import active_children as active_children, current_
|
||||
# multiprocessing.queues or the aliases defined below. See #4266 for discussion.
|
||||
from multiprocessing.queues import JoinableQueue as JoinableQueue, Queue as Queue, SimpleQueue as SimpleQueue
|
||||
from multiprocessing.spawn import freeze_support as freeze_support
|
||||
from typing import Any, overload
|
||||
from typing_extensions import Literal
|
||||
from typing import Any, TypeVar, overload
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from multiprocessing.process import parent_process as parent_process
|
||||
@@ -118,23 +118,24 @@ else:
|
||||
# from multiprocessing import _LockType
|
||||
# lock: _LockType = Lock()
|
||||
|
||||
_QueueType = Queue
|
||||
_SimpleQueueType = SimpleQueue
|
||||
_JoinableQueueType = JoinableQueue
|
||||
_BarrierType = synchronize.Barrier
|
||||
_BoundedSemaphoreType = synchronize.BoundedSemaphore
|
||||
_ConditionType = synchronize.Condition
|
||||
_EventType = synchronize.Event
|
||||
_LockType = synchronize.Lock
|
||||
_RLockType = synchronize.RLock
|
||||
_SemaphoreType = synchronize.Semaphore
|
||||
_T = TypeVar("_T")
|
||||
_QueueType: TypeAlias = Queue[_T]
|
||||
_SimpleQueueType: TypeAlias = SimpleQueue[_T]
|
||||
_JoinableQueueType: TypeAlias = JoinableQueue[_T]
|
||||
_BarrierType: TypeAlias = synchronize.Barrier
|
||||
_BoundedSemaphoreType: TypeAlias = synchronize.BoundedSemaphore
|
||||
_ConditionType: TypeAlias = synchronize.Condition
|
||||
_EventType: TypeAlias = synchronize.Event
|
||||
_LockType: TypeAlias = synchronize.Lock
|
||||
_RLockType: TypeAlias = synchronize.RLock
|
||||
_SemaphoreType: TypeAlias = synchronize.Semaphore
|
||||
|
||||
# N.B. The functions below are generated at runtime by partially applying
|
||||
# multiprocessing.context.BaseContext's methods, so the two signatures should
|
||||
# be identical (modulo self).
|
||||
|
||||
# Synchronization primitives
|
||||
_LockLike = synchronize.Lock | synchronize.RLock
|
||||
_LockLike: TypeAlias = synchronize.Lock | synchronize.RLock
|
||||
RawValue = context._default_context.RawValue
|
||||
RawArray = context._default_context.RawArray
|
||||
Value = context._default_context.Value
|
||||
|
||||
@@ -3,12 +3,12 @@ import sys
|
||||
import types
|
||||
from _typeshed import Self
|
||||
from typing import Any, Iterable, Union
|
||||
from typing_extensions import SupportsIndex
|
||||
from typing_extensions import SupportsIndex, TypeAlias
|
||||
|
||||
__all__ = ["Client", "Listener", "Pipe", "wait"]
|
||||
|
||||
# https://docs.python.org/3/library/multiprocessing.html#address-formats
|
||||
_Address = Union[str, tuple[str, int]]
|
||||
_Address: TypeAlias = Union[str, tuple[str, int]]
|
||||
|
||||
class _ConnectionBase:
|
||||
def __init__(self, handle: SupportsIndex, readable: bool = ..., writable: bool = ...) -> None: ...
|
||||
|
||||
@@ -9,14 +9,14 @@ from multiprocessing.pool import Pool as _Pool
|
||||
from multiprocessing.process import BaseProcess
|
||||
from multiprocessing.sharedctypes import SynchronizedArray, SynchronizedBase
|
||||
from typing import Any, ClassVar, TypeVar, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
__all__ = ()
|
||||
else:
|
||||
__all__: list[str] = []
|
||||
|
||||
_LockLike = synchronize.Lock | synchronize.RLock
|
||||
_LockLike: TypeAlias = synchronize.Lock | synchronize.RLock
|
||||
_CT = TypeVar("_CT", bound=_CData)
|
||||
|
||||
class ProcessError(Exception): ...
|
||||
|
||||
@@ -2,12 +2,13 @@ from _typeshed import Self
|
||||
from queue import Queue
|
||||
from types import TracebackType
|
||||
from typing import Any, Union
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = ["Client", "Listener", "Pipe"]
|
||||
|
||||
families: list[None]
|
||||
|
||||
_Address = Union[str, tuple[str, int]]
|
||||
_Address: TypeAlias = Union[str, tuple[str, int]]
|
||||
|
||||
class Connection:
|
||||
_in: Any
|
||||
|
||||
@@ -4,10 +4,11 @@ from contextlib import AbstractContextManager
|
||||
from multiprocessing.context import BaseContext
|
||||
from types import TracebackType
|
||||
from typing import Any, Callable
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = ["Lock", "RLock", "Semaphore", "BoundedSemaphore", "Condition", "Event"]
|
||||
|
||||
_LockLike = Lock | RLock
|
||||
_LockLike: TypeAlias = Lock | RLock
|
||||
|
||||
class Barrier(threading.Barrier):
|
||||
def __init__(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from _typeshed import StrOrBytesPath
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = ["netrc", "NetrcParseError"]
|
||||
|
||||
@@ -9,7 +10,7 @@ class NetrcParseError(Exception):
|
||||
def __init__(self, msg: str, filename: StrOrBytesPath | None = ..., lineno: int | None = ...) -> None: ...
|
||||
|
||||
# (login, account, password) tuple
|
||||
_NetrcTuple = tuple[str, str | None, str | None]
|
||||
_NetrcTuple: TypeAlias = tuple[str, str | None, str | None]
|
||||
|
||||
class netrc:
|
||||
hosts: dict[str, _NetrcTuple]
|
||||
|
||||
@@ -4,7 +4,7 @@ import ssl
|
||||
import sys
|
||||
from _typeshed import Self
|
||||
from typing import IO, Any, Iterable, NamedTuple
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
__all__ = [
|
||||
"NNTP",
|
||||
@@ -18,7 +18,7 @@ __all__ = [
|
||||
"NNTP_SSL",
|
||||
]
|
||||
|
||||
_File = IO[bytes] | bytes | str | None
|
||||
_File: TypeAlias = IO[bytes] | bytes | str | None
|
||||
|
||||
class NNTPError(Exception):
|
||||
response: str
|
||||
|
||||
@@ -35,7 +35,7 @@ from typing import (
|
||||
overload,
|
||||
runtime_checkable,
|
||||
)
|
||||
from typing_extensions import Final, Literal, final
|
||||
from typing_extensions import Final, Literal, TypeAlias, final
|
||||
|
||||
from . import path as _path
|
||||
|
||||
@@ -211,7 +211,7 @@ R_OK: int
|
||||
W_OK: int
|
||||
X_OK: int
|
||||
|
||||
_EnvironCodeFunc = Callable[[AnyStr], AnyStr]
|
||||
_EnvironCodeFunc: TypeAlias = Callable[[AnyStr], AnyStr]
|
||||
|
||||
class _Environ(MutableMapping[AnyStr, AnyStr], Generic[AnyStr]):
|
||||
encodekey: _EnvironCodeFunc[AnyStr]
|
||||
@@ -383,7 +383,7 @@ def listdir(path: BytesPath) -> list[bytes]: ...
|
||||
@overload
|
||||
def listdir(path: int) -> list[str]: ...
|
||||
|
||||
_FdOrAnyPath = int | StrOrBytesPath
|
||||
_FdOrAnyPath: TypeAlias = int | StrOrBytesPath
|
||||
|
||||
@final
|
||||
class DirEntry(Generic[AnyStr]):
|
||||
@@ -404,9 +404,9 @@ class DirEntry(Generic[AnyStr]):
|
||||
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
_StatVfsTuple = tuple[int, int, int, int, int, int, int, int, int, int, int]
|
||||
_StatVfsTuple: TypeAlias = tuple[int, int, int, int, int, int, int, int, int, int, int]
|
||||
else:
|
||||
_StatVfsTuple = tuple[int, int, int, int, int, int, int, int, int, int]
|
||||
_StatVfsTuple: TypeAlias = tuple[int, int, int, int, int, int, int, int, int, int]
|
||||
|
||||
@final
|
||||
class statvfs_result(structseq[int], _StatVfsTuple):
|
||||
@@ -527,7 +527,7 @@ def putenv(__name: bytes | str, __value: bytes | str) -> None: ...
|
||||
if sys.platform != "win32" or sys.version_info >= (3, 9):
|
||||
def unsetenv(__name: bytes | str) -> None: ...
|
||||
|
||||
_Opener = Callable[[str, int], int]
|
||||
_Opener: TypeAlias = Callable[[str, int], int]
|
||||
|
||||
@overload
|
||||
def fdopen(
|
||||
@@ -787,7 +787,7 @@ def utime(
|
||||
follow_symlinks: bool = ...,
|
||||
) -> None: ...
|
||||
|
||||
_OnError = Callable[[OSError], Any]
|
||||
_OnError: TypeAlias = Callable[[OSError], Any]
|
||||
|
||||
def walk(
|
||||
top: AnyStr | PathLike[AnyStr], topdown: bool = ..., onerror: _OnError | None = ..., followlinks: bool = ...
|
||||
@@ -845,7 +845,7 @@ def execlpe(file: StrOrBytesPath, __arg0: StrOrBytesPath, *args: Any) -> NoRetur
|
||||
# Not separating out PathLike[str] and PathLike[bytes] here because it doesn't make much difference
|
||||
# in practice, and doing so would explode the number of combinations in this already long union.
|
||||
# All these combinations are necessary due to list being invariant.
|
||||
_ExecVArgs = (
|
||||
_ExecVArgs: TypeAlias = (
|
||||
tuple[StrOrBytesPath, ...]
|
||||
| list[bytes]
|
||||
| list[str]
|
||||
@@ -855,7 +855,7 @@ _ExecVArgs = (
|
||||
| list[str | PathLike[Any]]
|
||||
| list[bytes | str | PathLike[Any]]
|
||||
)
|
||||
_ExecEnv = Mapping[bytes, bytes | str] | Mapping[str, bytes | str]
|
||||
_ExecEnv: TypeAlias = Mapping[bytes, bytes | str] | Mapping[str, bytes | str]
|
||||
|
||||
def execv(__path: StrOrBytesPath, __argv: _ExecVArgs) -> NoReturn: ...
|
||||
def execve(path: _FdOrAnyPath, argv: _ExecVArgs, env: _ExecEnv) -> NoReturn: ...
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import sys
|
||||
from typing import Any, Callable, ClassVar, Iterable, Iterator, Mapping, Protocol, Union
|
||||
from typing_extensions import final
|
||||
from typing_extensions import TypeAlias, final
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
__all__ = [
|
||||
@@ -189,7 +189,7 @@ if sys.version_info >= (3, 8):
|
||||
def __init__(self, buffer: Any) -> None: ...
|
||||
def raw(self) -> memoryview: ...
|
||||
def release(self) -> None: ...
|
||||
_BufferCallback = Callable[[PickleBuffer], Any] | None
|
||||
_BufferCallback: TypeAlias = Callable[[PickleBuffer], Any] | None
|
||||
def dump(
|
||||
obj: Any,
|
||||
file: _WritableFileobj,
|
||||
@@ -223,7 +223,7 @@ class PickleError(Exception): ...
|
||||
class PicklingError(PickleError): ...
|
||||
class UnpicklingError(PickleError): ...
|
||||
|
||||
_reducedtype = Union[
|
||||
_reducedtype: TypeAlias = Union[
|
||||
str,
|
||||
tuple[Callable[..., Any], tuple[Any, ...]],
|
||||
tuple[Callable[..., Any], tuple[Any, ...], Any],
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from typing import IO, Any, Callable, Iterator, MutableMapping
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = ["dis", "genops", "optimize"]
|
||||
|
||||
_Reader = Callable[[IO[bytes]], Any]
|
||||
_Reader: TypeAlias = Callable[[IO[bytes]], Any]
|
||||
bytes_types: tuple[type[Any], ...]
|
||||
|
||||
UP_TO_NEWLINE: int
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import socket
|
||||
import ssl
|
||||
from typing import Any, BinaryIO, NoReturn, Pattern, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
__all__ = ["POP3", "error_proto", "POP3_SSL"]
|
||||
|
||||
_LongResp = tuple[bytes, list[bytes], int]
|
||||
_LongResp: TypeAlias = tuple[bytes, list[bytes], int]
|
||||
|
||||
class error_proto(Exception): ...
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from _typeshed import Self, StrOrBytesPath
|
||||
from typing import Any, Callable, TypeVar
|
||||
from typing_extensions import ParamSpec
|
||||
from typing_extensions import ParamSpec, TypeAlias
|
||||
|
||||
__all__ = ["run", "runctx", "Profile"]
|
||||
|
||||
@@ -11,7 +11,7 @@ def runctx(
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_P = ParamSpec("_P")
|
||||
_Label = tuple[str, int, str]
|
||||
_Label: TypeAlias = tuple[str, int, str]
|
||||
|
||||
class Profile:
|
||||
bias: int
|
||||
|
||||
@@ -3,7 +3,7 @@ from _typeshed import Self, StrOrBytesPath
|
||||
from cProfile import Profile as _cProfile
|
||||
from profile import Profile
|
||||
from typing import IO, Any, Iterable, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
__all__ = ["Stats", "SortKey", "FunctionProfile", "StatsProfile"]
|
||||
@@ -12,7 +12,7 @@ elif sys.version_info >= (3, 7):
|
||||
else:
|
||||
__all__ = ["Stats"]
|
||||
|
||||
_Selector = str | float | int
|
||||
_Selector: TypeAlias = str | float | int
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from enum import Enum
|
||||
@@ -45,7 +45,7 @@ if sys.version_info >= (3, 9):
|
||||
total_tt: float
|
||||
func_profiles: dict[str, FunctionProfile]
|
||||
|
||||
_SortArgDict = dict[str, tuple[tuple[tuple[int, int], ...], str]]
|
||||
_SortArgDict: TypeAlias = dict[str, tuple[tuple[tuple[int, int], ...], str]]
|
||||
|
||||
class Stats:
|
||||
sort_arg_dict_default: _SortArgDict
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import sys
|
||||
from typing import Callable, Iterable
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
if sys.platform != "win32":
|
||||
__all__ = ["openpty", "fork", "spawn"]
|
||||
_Reader = Callable[[int], bytes]
|
||||
_Reader: TypeAlias = Callable[[int], bytes]
|
||||
|
||||
STDIN_FILENO: Literal[0]
|
||||
STDOUT_FILENO: Literal[1]
|
||||
|
||||
@@ -3,11 +3,12 @@ from abc import abstractmethod
|
||||
from reprlib import Repr
|
||||
from types import MethodType, ModuleType, TracebackType
|
||||
from typing import IO, Any, AnyStr, Callable, Container, Mapping, MutableMapping, NoReturn, TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = ["help"]
|
||||
|
||||
# the return type of sys.exc_info(), used by ErrorDuringImport.__init__
|
||||
_Exc_Info = tuple[type[BaseException] | None, BaseException | None, TracebackType | None]
|
||||
_Exc_Info: TypeAlias = tuple[type[BaseException] | None, BaseException | None, TracebackType | None]
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import pyexpat.errors as errors
|
||||
import pyexpat.model as model
|
||||
from _typeshed import SupportsRead
|
||||
from typing import Any, Callable
|
||||
from typing_extensions import final
|
||||
from typing_extensions import TypeAlias, final
|
||||
|
||||
EXPAT_VERSION: str # undocumented
|
||||
version_info: tuple[int, int, int] # undocumented
|
||||
@@ -20,7 +20,7 @@ XML_PARAM_ENTITY_PARSING_NEVER: int
|
||||
XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE: int
|
||||
XML_PARAM_ENTITY_PARSING_ALWAYS: int
|
||||
|
||||
_Model = tuple[int, int, str | None, tuple[Any, ...]]
|
||||
_Model: TypeAlias = tuple[int, int, str | None, tuple[Any, ...]]
|
||||
|
||||
@final
|
||||
class XMLParserType:
|
||||
|
||||
@@ -3,6 +3,7 @@ import sre_compile
|
||||
import sys
|
||||
from sre_constants import error as error
|
||||
from typing import Any, AnyStr, Callable, Iterator, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
# ----- re variables and constants -----
|
||||
if sys.version_info >= (3, 7):
|
||||
@@ -147,7 +148,7 @@ T = RegexFlag.T
|
||||
TEMPLATE = RegexFlag.TEMPLATE
|
||||
if sys.version_info >= (3, 11):
|
||||
NOFLAG = RegexFlag.NOFLAG
|
||||
_FlagsType = int | RegexFlag
|
||||
_FlagsType: TypeAlias = int | RegexFlag
|
||||
|
||||
if sys.version_info < (3, 7):
|
||||
# undocumented
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import sys
|
||||
from _typeshed import StrOrBytesPath
|
||||
from typing import Callable, Sequence
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.platform != "win32":
|
||||
_Completer = Callable[[str, int], str | None]
|
||||
_CompDisp = Callable[[str, Sequence[str], int], None]
|
||||
_Completer: TypeAlias = Callable[[str, int], str | None]
|
||||
_CompDisp: TypeAlias = Callable[[str, Sequence[str], int], None]
|
||||
|
||||
def parse_and_bind(__string: str) -> None: ...
|
||||
def read_init_file(__filename: StrOrBytesPath | None = ...) -> None: ...
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
from array import array
|
||||
from collections import deque
|
||||
from typing import Any, Callable
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = ["Repr", "repr", "recursive_repr"]
|
||||
|
||||
_ReprFunc = Callable[[Any], str]
|
||||
_ReprFunc: TypeAlias = Callable[[Any], str]
|
||||
|
||||
def recursive_repr(fillvalue: str = ...) -> Callable[[_ReprFunc], _ReprFunc]: ...
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import os
|
||||
import sys
|
||||
from _typeshed import BytesPath, StrOrBytesPath, StrPath, SupportsRead, SupportsWrite
|
||||
from typing import Any, AnyStr, Callable, Iterable, NamedTuple, Sequence, TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = [
|
||||
"copyfileobj",
|
||||
@@ -82,7 +83,7 @@ else:
|
||||
|
||||
def rmtree(path: StrOrBytesPath, ignore_errors: bool = ..., onerror: Callable[[Any, Any, Any], Any] | None = ...) -> None: ...
|
||||
|
||||
_CopyFn = Callable[[str, str], None] | Callable[[StrPath, StrPath], None]
|
||||
_CopyFn: TypeAlias = Callable[[str, str], None] | Callable[[StrPath, StrPath], None]
|
||||
|
||||
# N.B. shutil.move appears to take bytes arguments, however,
|
||||
# this does not work when dst is (or is within) an existing directory.
|
||||
|
||||
@@ -3,7 +3,7 @@ from _typeshed import structseq
|
||||
from enum import IntEnum
|
||||
from types import FrameType
|
||||
from typing import Any, Callable, Iterable, Union
|
||||
from typing_extensions import Final, final
|
||||
from typing_extensions import Final, TypeAlias, final
|
||||
|
||||
NSIG: int
|
||||
|
||||
@@ -60,8 +60,8 @@ class Handlers(IntEnum):
|
||||
SIG_DFL: Handlers
|
||||
SIG_IGN: Handlers
|
||||
|
||||
_SIGNUM = int | Signals
|
||||
_HANDLER = Union[Callable[[int, FrameType | None], Any], int, Handlers, None]
|
||||
_SIGNUM: TypeAlias = int | Signals
|
||||
_HANDLER: TypeAlias = Union[Callable[[int, FrameType | None], Any], int, Handlers, None]
|
||||
|
||||
def default_int_handler(__signalnum: int, __frame: FrameType | None) -> None: ...
|
||||
|
||||
|
||||
@@ -4,13 +4,14 @@ import socket
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
from typing import Any
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
__all__ = ["SMTPChannel", "SMTPServer", "DebuggingServer", "PureProxy"]
|
||||
else:
|
||||
__all__ = ["SMTPChannel", "SMTPServer", "DebuggingServer", "PureProxy", "MailmanProxy"]
|
||||
|
||||
_Address = tuple[str, int] # (host, port)
|
||||
_Address: TypeAlias = tuple[str, int] # (host, port)
|
||||
|
||||
class SMTPChannel(asynchat.async_chat):
|
||||
COMMAND: int
|
||||
|
||||
@@ -5,6 +5,7 @@ from socket import socket
|
||||
from ssl import SSLContext
|
||||
from types import TracebackType
|
||||
from typing import Any, Pattern, Protocol, Sequence, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
__all__ = [
|
||||
@@ -40,10 +41,10 @@ else:
|
||||
"SMTP_SSL",
|
||||
]
|
||||
|
||||
_Reply = tuple[int, bytes]
|
||||
_SendErrs = dict[str, _Reply]
|
||||
_Reply: TypeAlias = tuple[int, bytes]
|
||||
_SendErrs: TypeAlias = dict[str, _Reply]
|
||||
# Should match source_address for socket.create_connection
|
||||
_SourceAddress = tuple[bytearray | bytes | str, int]
|
||||
_SourceAddress: TypeAlias = tuple[bytearray | bytes | str, int]
|
||||
|
||||
SMTP_PORT: int
|
||||
SMTP_SSL_PORT: int
|
||||
|
||||
@@ -3,6 +3,7 @@ import types
|
||||
from _typeshed import Self
|
||||
from socket import socket as _socket
|
||||
from typing import Any, BinaryIO, Callable, ClassVar, Union
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.platform == "win32":
|
||||
__all__ = [
|
||||
@@ -36,8 +37,8 @@ else:
|
||||
"ThreadingUnixDatagramServer",
|
||||
]
|
||||
|
||||
_RequestType = Union[_socket, tuple[bytes, _socket]]
|
||||
_AddressType = Union[tuple[str, int], str]
|
||||
_RequestType: TypeAlias = Union[_socket, tuple[bytes, _socket]]
|
||||
_AddressType: TypeAlias = Union[tuple[str, int], str]
|
||||
|
||||
# This can possibly be generic at some point:
|
||||
class BaseServer:
|
||||
|
||||
@@ -2,6 +2,7 @@ import sys
|
||||
from sre_constants import *
|
||||
from sre_constants import _NamedIntConstant as _NIC, error as _Error
|
||||
from typing import Any, Iterable, Match, Pattern as _Pattern, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
SPECIAL_CHARS: str
|
||||
REPEAT_CHARS: str
|
||||
@@ -33,16 +34,16 @@ class _State:
|
||||
def checklookbehindgroup(self, gid: int, source: Tokenizer) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
State = _State
|
||||
State: TypeAlias = _State
|
||||
else:
|
||||
Pattern = _State
|
||||
Pattern: TypeAlias = _State
|
||||
|
||||
_OpSubpatternType = tuple[int | None, int, int, SubPattern]
|
||||
_OpGroupRefExistsType = tuple[int, SubPattern, SubPattern]
|
||||
_OpInType = list[tuple[_NIC, int]]
|
||||
_OpBranchType = tuple[None, list[SubPattern]]
|
||||
_AvType = _OpInType | _OpBranchType | Iterable[SubPattern] | _OpGroupRefExistsType | _OpSubpatternType
|
||||
_CodeType = tuple[_NIC, _AvType]
|
||||
_OpSubpatternType: TypeAlias = tuple[int | None, int, int, SubPattern]
|
||||
_OpGroupRefExistsType: TypeAlias = tuple[int, SubPattern, SubPattern]
|
||||
_OpInType: TypeAlias = list[tuple[_NIC, int]]
|
||||
_OpBranchType: TypeAlias = tuple[None, list[SubPattern]]
|
||||
_AvType: TypeAlias = _OpInType | _OpBranchType | Iterable[SubPattern] | _OpGroupRefExistsType | _OpSubpatternType
|
||||
_CodeType: TypeAlias = tuple[_NIC, _AvType]
|
||||
|
||||
class SubPattern:
|
||||
data: list[_CodeType]
|
||||
@@ -87,8 +88,8 @@ class Tokenizer:
|
||||
|
||||
def fix_flags(src: str | bytes, flags: int) -> int: ...
|
||||
|
||||
_TemplateType = tuple[list[tuple[int, int]], list[str | None]]
|
||||
_TemplateByteType = tuple[list[tuple[int, int]], list[bytes | None]]
|
||||
_TemplateType: TypeAlias = tuple[list[tuple[int, int]], list[str | None]]
|
||||
_TemplateByteType: TypeAlias = tuple[list[tuple[int, int]], list[bytes | None]]
|
||||
if sys.version_info >= (3, 8):
|
||||
def parse(str: str, flags: int = ..., state: State | None = ...) -> SubPattern: ...
|
||||
@overload
|
||||
|
||||
@@ -3,16 +3,16 @@ import socket
|
||||
import sys
|
||||
from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer
|
||||
from typing import Any, Callable, Iterable, NamedTuple, Union, overload
|
||||
from typing_extensions import Literal, TypedDict, final
|
||||
from typing_extensions import Literal, TypeAlias, TypedDict, final
|
||||
|
||||
_PCTRTT = tuple[tuple[str, str], ...]
|
||||
_PCTRTTT = tuple[_PCTRTT, ...]
|
||||
_PeerCertRetDictType = dict[str, str | _PCTRTTT | _PCTRTT]
|
||||
_PeerCertRetType = _PeerCertRetDictType | bytes | None
|
||||
_EnumRetType = list[tuple[bytes, str, set[str] | bool]]
|
||||
_PasswordType = Union[Callable[[], str | bytes], str, bytes]
|
||||
_PCTRTT: TypeAlias = tuple[tuple[str, str], ...]
|
||||
_PCTRTTT: TypeAlias = tuple[_PCTRTT, ...]
|
||||
_PeerCertRetDictType: TypeAlias = dict[str, str | _PCTRTTT | _PCTRTT]
|
||||
_PeerCertRetType: TypeAlias = _PeerCertRetDictType | bytes | None
|
||||
_EnumRetType: TypeAlias = list[tuple[bytes, str, set[str] | bool]]
|
||||
_PasswordType: TypeAlias = Union[Callable[[], str | bytes], str, bytes]
|
||||
|
||||
_SrvnmeCbType = Callable[[SSLSocket | SSLObject, str | None, SSLSocket], int | None]
|
||||
_SrvnmeCbType: TypeAlias = Callable[[SSLSocket | SSLObject, str | None, SSLSocket], int | None]
|
||||
|
||||
class _Cipher(TypedDict):
|
||||
aead: bool
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user