mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-20 16:48:27 +08:00
Use TypeAlias where possible for type aliases (#7630)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
from typing import Any, Callable, TypeVar, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
_F = TypeVar("_F", bound=Callable[..., Any])
|
||||
_Actions = Literal["default", "error", "ignore", "always", "module", "once"]
|
||||
_Actions: TypeAlias = Literal["default", "error", "ignore", "always", "module", "once"]
|
||||
|
||||
class ClassicAdapter:
|
||||
reason: str
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
from datetime import timedelta
|
||||
from logging import Logger
|
||||
from typing import Any, Iterable, Pattern, TypeVar, overload
|
||||
from typing_extensions import TypedDict
|
||||
from typing_extensions import TypeAlias, TypedDict
|
||||
|
||||
_IterableT = TypeVar("_IterableT", bound=Iterable[Any])
|
||||
_T = TypeVar("_T")
|
||||
_App = Any # flask is not part of typeshed
|
||||
_Response = Any # flask is not part of typeshed
|
||||
_MultiDict = Any # werkzeug is not part of typeshed
|
||||
_App: TypeAlias = Any # flask is not part of typeshed
|
||||
_Response: TypeAlias = Any # flask is not part of typeshed
|
||||
_MultiDict: TypeAlias = Any # werkzeug is not part of typeshed
|
||||
|
||||
class _Options(TypedDict, total=False):
|
||||
resources: dict[str, dict[str, Any]] | list[str] | str | None
|
||||
@@ -35,7 +35,7 @@ ACL_REQUEST_HEADERS: str
|
||||
ALL_METHODS: list[str]
|
||||
CONFIG_OPTIONS: list[str]
|
||||
FLASK_CORS_EVALUATED: str
|
||||
RegexObject = Pattern[str]
|
||||
RegexObject: TypeAlias = Pattern[str]
|
||||
DEFAULT_OPTIONS: _Options
|
||||
|
||||
def parse_resources(resources: dict[str, _Options] | Iterable[str] | str | Pattern[str]) -> list[tuple[str, _Options]]: ...
|
||||
|
||||
@@ -2,7 +2,7 @@ from _typeshed import Self, SupportsRead, SupportsWrite
|
||||
from collections.abc import Iterable, Iterator, MutableMapping
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, ClassVar, Protocol, Sequence, SupportsBytes, Union
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from ._imaging import (
|
||||
DEFAULT_STRATEGY as DEFAULT_STRATEGY,
|
||||
@@ -14,15 +14,15 @@ from ._imaging import (
|
||||
from .ImageFilter import Filter
|
||||
from .ImagePalette import ImagePalette
|
||||
|
||||
_Mode = Literal["1", "CMYK", "F", "HSV", "I", "L", "LAB", "P", "RGB", "RGBA", "RGBX", "YCbCr"]
|
||||
_Resample = Literal[0, 1, 2, 3, 4, 5]
|
||||
_Size = tuple[int, int]
|
||||
_Box = tuple[int, int, int, int]
|
||||
_Mode: TypeAlias = Literal["1", "CMYK", "F", "HSV", "I", "L", "LAB", "P", "RGB", "RGBA", "RGBX", "YCbCr"]
|
||||
_Resample: TypeAlias = Literal[0, 1, 2, 3, 4, 5]
|
||||
_Size: TypeAlias = tuple[int, int]
|
||||
_Box: TypeAlias = tuple[int, int, int, int]
|
||||
|
||||
_ConversionMatrix = Union[
|
||||
_ConversionMatrix: TypeAlias = Union[
|
||||
tuple[float, float, float, float], tuple[float, float, float, float, float, float, float, float, float, float, float, float],
|
||||
]
|
||||
_Color = float | tuple[float, ...]
|
||||
_Color: TypeAlias = float | tuple[float, ...]
|
||||
|
||||
class _Writeable(SupportsWrite[bytes], Protocol):
|
||||
def seek(self, __offset: int) -> Any: ...
|
||||
@@ -99,7 +99,7 @@ class _E:
|
||||
def __add__(self, other) -> _E: ...
|
||||
def __mul__(self, other) -> _E: ...
|
||||
|
||||
_ImageState = tuple[dict[str, Any], str, tuple[int, int], Any, bytes]
|
||||
_ImageState: TypeAlias = tuple[dict[str, Any], str, tuple[int, int], Any, bytes]
|
||||
|
||||
class Image:
|
||||
format: ClassVar[str | None]
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from typing import Union
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_RGB = Union[tuple[int, int, int], tuple[int, int, int, int]]
|
||||
_Ink = str | int | _RGB
|
||||
_GreyScale = tuple[int, int]
|
||||
_RGB: TypeAlias = Union[tuple[int, int, int], tuple[int, int, int, int]]
|
||||
_Ink: TypeAlias = str | int | _RGB
|
||||
_GreyScale: TypeAlias = tuple[int, int]
|
||||
|
||||
def getrgb(color: _Ink) -> _RGB: ...
|
||||
def getcolor(color: _Ink, mode: str) -> _RGB | _GreyScale: ...
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
from collections.abc import Container
|
||||
from typing import Any, Sequence, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from .Image import Image
|
||||
from .ImageColor import _Ink
|
||||
from .ImageFont import _Font
|
||||
|
||||
_XY = Sequence[float | tuple[float, float]]
|
||||
_Outline = Any
|
||||
_XY: TypeAlias = Sequence[float | tuple[float, float]]
|
||||
_Outline: TypeAlias = Any
|
||||
|
||||
class ImageDraw:
|
||||
def __init__(self, im: Image, mode: str | None = ...) -> None: ...
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from _typeshed import Self
|
||||
from typing import Any, Callable, Iterable, Sequence
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from .Image import Image
|
||||
|
||||
_FilterArgs = tuple[Sequence[int], int, int, Sequence[int]]
|
||||
_FilterArgs: TypeAlias = tuple[Sequence[int], int, int, Sequence[int]]
|
||||
|
||||
# filter image parameters below are the C images, i.e. Image().im.
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
from typing import Any, Iterable, Protocol, Union
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from .Image import Image, _Resample, _Size
|
||||
from .ImageColor import _Ink
|
||||
|
||||
_Border = Union[int, tuple[int, int], tuple[int, int, int, int]]
|
||||
_Border: TypeAlias = Union[int, tuple[int, int], tuple[int, int, int, int]]
|
||||
|
||||
class _Deformer(Protocol):
|
||||
def getmesh(self, image: Image): ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from typing import Any, NamedTuple, Union
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
class _TagInfo(NamedTuple):
|
||||
value: Any
|
||||
@@ -35,8 +35,8 @@ FLOAT: Literal[11]
|
||||
DOUBLE: Literal[12]
|
||||
IFD: Literal[13]
|
||||
|
||||
_TagType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
|
||||
_TagTuple = Union[tuple[str, _TagType, int], tuple[str, _TagInfo, int, dict[str, int]]]
|
||||
_TagType: TypeAlias = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
|
||||
_TagTuple: TypeAlias = Union[tuple[str, _TagType, int], tuple[str, _TagInfo, int, dict[str, int]]]
|
||||
|
||||
TAGS_V2: dict[int, _TagTuple]
|
||||
TAGS_V2_GROUPS: dict[int, dict[int, _TagTuple]]
|
||||
|
||||
@@ -3,8 +3,9 @@ import time
|
||||
from collections.abc import Callable, Mapping, Sequence
|
||||
from decimal import Decimal
|
||||
from typing import Any, TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_EscaperMapping = Mapping[type[object], Callable[..., str]] | None
|
||||
_EscaperMapping: TypeAlias = Mapping[type[object], Callable[..., str]] | None
|
||||
_T = TypeVar("_T")
|
||||
|
||||
def escape_item(val: object, charset: object, mapping: _EscaperMapping = ...) -> str: ...
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
from typing import Any, Pattern
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from yaml.error import MarkedYAMLError
|
||||
from yaml.nodes import ScalarNode
|
||||
|
||||
_Scalar = str | int | float | bool | None
|
||||
_Scalar: TypeAlias = str | int | float | bool | None
|
||||
|
||||
class ConstructorError(MarkedYAMLError): ...
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from _typeshed import SupportsRead
|
||||
from collections.abc import Mapping, Sequence
|
||||
from typing import IO, Any
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from ._yaml import CEmitter, CParser
|
||||
from .constructor import BaseConstructor, FullConstructor, SafeConstructor, UnsafeConstructor
|
||||
@@ -9,7 +10,7 @@ from .resolver import BaseResolver, Resolver
|
||||
|
||||
__all__ = ["CBaseLoader", "CSafeLoader", "CFullLoader", "CUnsafeLoader", "CLoader", "CBaseDumper", "CSafeDumper", "CDumper"]
|
||||
|
||||
_Readable = SupportsRead[str | bytes]
|
||||
_Readable: TypeAlias = SupportsRead[str | bytes]
|
||||
|
||||
class CBaseLoader(CParser, BaseConstructor, BaseResolver):
|
||||
def __init__(self, stream: str | bytes | _Readable) -> None: ...
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
from _typeshed import SupportsRead
|
||||
from typing import Any
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from yaml.error import YAMLError
|
||||
|
||||
_ReadStream = str | bytes | SupportsRead[str] | SupportsRead[bytes]
|
||||
_ReadStream: TypeAlias = str | bytes | SupportsRead[str] | SupportsRead[bytes]
|
||||
|
||||
class ReaderError(YAMLError):
|
||||
name: Any
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
from _typeshed import StrOrBytesPath, StrPath
|
||||
from collections.abc import Iterator
|
||||
from typing import Any
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from pygments.lexer import Lexer, LexerMeta
|
||||
|
||||
_OpenFile = StrOrBytesPath | int # copy/pasted from builtins.pyi
|
||||
_OpenFile: TypeAlias = StrOrBytesPath | int # copy/pasted from builtins.pyi
|
||||
|
||||
def get_all_lexers() -> Iterator[tuple[str, tuple[str, ...], tuple[str, ...], tuple[str, ...]]]: ...
|
||||
def find_lexer_class(name: str) -> LexerMeta | None: ...
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
|
||||
from collections.abc import Mapping, Sequence
|
||||
from typing import Any, Protocol
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
DBAPITypeCode = Any | None
|
||||
DBAPITypeCode: TypeAlias = Any | None
|
||||
# Strictly speaking, this should be a Sequence, but the type system does
|
||||
# not support fixed-length sequences.
|
||||
DBAPIColumnDescription = tuple[str, DBAPITypeCode, int | None, int | None, int | None, int | None, bool | None]
|
||||
DBAPIColumnDescription: TypeAlias = tuple[str, DBAPITypeCode, int | None, int | None, int | None, int | None, bool | None]
|
||||
|
||||
class DBAPIConnection(Protocol):
|
||||
def close(self) -> object: ...
|
||||
|
||||
@@ -3,6 +3,7 @@ from abc import abstractmethod
|
||||
from collections.abc import Mapping
|
||||
from types import TracebackType
|
||||
from typing import Any, Callable, TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from ..dbapi import DBAPIConnection
|
||||
from ..log import Identified, _EchoFlag, echo_property
|
||||
@@ -19,7 +20,7 @@ from .util import TransactionalContext
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
_Executable = ClauseElement | FunctionElement | DDLElement | DefaultGenerator | Compiled
|
||||
_Executable: TypeAlias = ClauseElement | FunctionElement | DDLElement | DefaultGenerator | Compiled
|
||||
|
||||
class Connection(Connectable):
|
||||
engine: Engine
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from _typeshed import Self, SupportsItems
|
||||
from collections.abc import Iterable, Mapping, Sequence
|
||||
from typing import Any, NamedTuple
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from ..util import immutabledict
|
||||
from .interfaces import Dialect
|
||||
@@ -15,7 +16,7 @@ class _URLTuple(NamedTuple):
|
||||
database: str | None
|
||||
query: immutabledict[str, str | tuple[str, ...]]
|
||||
|
||||
_Query = Mapping[str, str | Sequence[str]] | Sequence[tuple[str, str | Sequence[str]]]
|
||||
_Query: TypeAlias = Mapping[str, str | Sequence[str]] | Sequence[tuple[str, str | Sequence[str]]]
|
||||
|
||||
class URL(_URLTuple):
|
||||
@classmethod
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from _typeshed import Self
|
||||
from logging import Logger
|
||||
from typing import Any, TypeVar, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
_ClsT = TypeVar("_ClsT", bound=type)
|
||||
_EchoFlag = bool | Literal["debug"] | None
|
||||
_EchoFlag: TypeAlias = bool | Literal["debug"] | None
|
||||
|
||||
rootlogger: Any
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from collections.abc import Callable
|
||||
from typing import Any, ClassVar, TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from ..engine.interfaces import Connectable
|
||||
from ..sql.schema import MetaData
|
||||
@@ -21,7 +22,7 @@ class _DeclarativeBase(Any): # super classes are dynamic
|
||||
__class_getitem__: ClassVar[Any]
|
||||
|
||||
# Meta class (or function) that creates a _DeclarativeBase class.
|
||||
_DeclarativeBaseMeta = Callable[[str, tuple[type[Any], ...], dict[str, Any]], _DeclT]
|
||||
_DeclarativeBaseMeta: TypeAlias = Callable[[str, tuple[type[Any], ...], dict[str, Any]], _DeclT]
|
||||
|
||||
def has_inherited_table(cls: type[Any]) -> bool: ...
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import sys
|
||||
from _typeshed import Self, SupportsKeysAndGetItem
|
||||
from collections.abc import Callable, Iterable, Iterator, Mapping
|
||||
from typing import Any, Generic, NoReturn, TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from ..cimmutabledict import immutabledict as immutabledict
|
||||
from ..sql.elements import ColumnElement
|
||||
@@ -178,7 +179,7 @@ class WeakPopulateDict(dict[Any, Any]):
|
||||
|
||||
column_set = set
|
||||
column_dict = dict
|
||||
ordered_column_set = OrderedSet[ColumnElement[Any]]
|
||||
ordered_column_set: TypeAlias = OrderedSet[ColumnElement[Any]]
|
||||
|
||||
def unique_list(seq: Iterable[_T], hashfunc: Callable[[_T], Any] | None = ...) -> list[_T]: ...
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@ from _typeshed import StrOrBytesPath
|
||||
from asyncio.events import AbstractEventLoop
|
||||
from os import stat_result
|
||||
from typing import Any, Sequence, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from . import ospath as path
|
||||
|
||||
_FdOrAnyPath = int | StrOrBytesPath
|
||||
_FdOrAnyPath: TypeAlias = int | StrOrBytesPath
|
||||
|
||||
async def stat(
|
||||
path: _FdOrAnyPath, # noqa: F811
|
||||
|
||||
@@ -8,14 +8,14 @@ from _typeshed import (
|
||||
)
|
||||
from asyncio import AbstractEventLoop
|
||||
from typing import Any, Callable, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from ..base import AiofilesContextManager
|
||||
from .binary import AsyncBufferedIOBase, AsyncBufferedReader, AsyncFileIO, _UnknownAsyncBinaryIO
|
||||
from .text import AsyncTextIOWrapper
|
||||
|
||||
_OpenFile = StrOrBytesPath | int
|
||||
_Opener = Callable[[str, int], int]
|
||||
_OpenFile: TypeAlias = StrOrBytesPath | int
|
||||
_Opener: TypeAlias = Callable[[str, int], int]
|
||||
|
||||
# Text mode: always returns AsyncTextIOWrapper
|
||||
@overload
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from _typeshed import SupportsLenAndGetItem
|
||||
from typing import overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
_Vector = SupportsLenAndGetItem[float]
|
||||
_Vector: TypeAlias = SupportsLenAndGetItem[float]
|
||||
|
||||
class AnnoyIndex:
|
||||
f: int
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from typing import Any
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
class UnknownLocaleError(Exception):
|
||||
identifier: Any
|
||||
@@ -115,7 +115,7 @@ def parse_locale(identifier, sep: str = ...): ...
|
||||
def get_locale_identifier(tup, sep: str = ...): ...
|
||||
def get_global(key: _GLOBAL_KEY): ...
|
||||
|
||||
_GLOBAL_KEY = Literal[
|
||||
_GLOBAL_KEY: TypeAlias = Literal[
|
||||
"all_currencies",
|
||||
"currency_fractions",
|
||||
"language_aliases",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from datetime import date, datetime, time, timedelta, tzinfo
|
||||
from typing import Any, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from babel.core import Locale
|
||||
from babel.util import LOCALTZ as LOCALTZ, UTC as UTC
|
||||
@@ -10,8 +10,8 @@ from pytz import BaseTzInfo
|
||||
# http://babel.pocoo.org/en/latest/api/dates.html
|
||||
|
||||
# Date and Time Formatting
|
||||
_Instant = date | time | datetime | float | None
|
||||
_PredefinedTimeFormat = Literal["full", "long", "medium", "short"]
|
||||
_Instant: TypeAlias = date | time | datetime | float | None
|
||||
_PredefinedTimeFormat: TypeAlias = Literal["full", "long", "medium", "short"]
|
||||
|
||||
def format_datetime(
|
||||
datetime: _Instant = ..., format: _PredefinedTimeFormat | str = ..., tzinfo: tzinfo | None = ..., locale: str | Locale = ...
|
||||
@@ -57,7 +57,7 @@ def get_timezone_gmt(
|
||||
return_z: bool = ...,
|
||||
) -> str: ...
|
||||
|
||||
_DtOrTzinfo = datetime | tzinfo | str | int | time | None
|
||||
_DtOrTzinfo: TypeAlias = datetime | tzinfo | str | int | time | None
|
||||
|
||||
def get_timezone_location(dt_or_tzinfo: _DtOrTzinfo = ..., locale: str | Locale = ..., return_city: bool = ...) -> str: ...
|
||||
def get_timezone_name(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from _typeshed import Self
|
||||
from collections.abc import Iterator
|
||||
from typing import Any, Callable, Generic, Iterable, Pattern, TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from . import BeautifulSoup
|
||||
from .builder import TreeBuilder
|
||||
@@ -27,10 +28,10 @@ class ContentMetaAttributeValue(AttributeValueWithCharsetSubstitution):
|
||||
def encode(self, encoding: str) -> str: ... # type: ignore[override] # incompatible with str
|
||||
|
||||
_PageElementT = TypeVar("_PageElementT", bound=PageElement)
|
||||
_SimpleStrainable = str | bool | None | bytes | Pattern[str] | Callable[[str], bool] | Callable[[Tag], bool]
|
||||
_Strainable = _SimpleStrainable | Iterable[_SimpleStrainable]
|
||||
_SimpleNormalizedStrainable = str | bool | None | Pattern[str] | Callable[[str], bool] | Callable[[Tag], bool]
|
||||
_NormalizedStrainable = _SimpleNormalizedStrainable | Iterable[_SimpleNormalizedStrainable]
|
||||
_SimpleStrainable: TypeAlias = str | bool | None | bytes | Pattern[str] | Callable[[str], bool] | Callable[[Tag], bool]
|
||||
_Strainable: TypeAlias = _SimpleStrainable | Iterable[_SimpleStrainable]
|
||||
_SimpleNormalizedStrainable: TypeAlias = str | bool | None | Pattern[str] | Callable[[str], bool] | Callable[[Tag], bool]
|
||||
_NormalizedStrainable: TypeAlias = _SimpleNormalizedStrainable | Iterable[_SimpleNormalizedStrainable]
|
||||
|
||||
class PageElement:
|
||||
parent: Tag | None
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from typing import Callable
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from .dammit import EntitySubstitution as EntitySubstitution
|
||||
|
||||
_EntitySubstitution = Callable[[str], str]
|
||||
_EntitySubstitution: TypeAlias = Callable[[str], str]
|
||||
|
||||
class Formatter(EntitySubstitution):
|
||||
HTML: str
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
from collections.abc import MutableMapping
|
||||
from typing import Any
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_Attrs = MutableMapping[Any, str]
|
||||
_Attrs: TypeAlias = MutableMapping[Any, str]
|
||||
|
||||
def nofollow(attrs: _Attrs, new: bool = ...) -> _Attrs: ...
|
||||
def target_blank(attrs: _Attrs, new: bool = ...) -> _Attrs: ...
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
from collections.abc import Container, Iterable, MutableMapping
|
||||
from typing import Any, Pattern, Protocol
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from .html5lib_shim import Filter
|
||||
|
||||
_Attrs = MutableMapping[Any, str]
|
||||
_Attrs: TypeAlias = MutableMapping[Any, str]
|
||||
|
||||
class _Callback(Protocol):
|
||||
def __call__(self, attrs: _Attrs, new: bool = ...) -> _Attrs: ...
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from collections.abc import Callable, Container, Iterable
|
||||
from typing import Any, Pattern
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from .css_sanitizer import CSSSanitizer
|
||||
from .html5lib_shim import BleachHTMLParser, BleachHTMLSerializer, SanitizerFilter
|
||||
@@ -38,9 +39,9 @@ class Cleaner:
|
||||
) -> None: ...
|
||||
def clean(self, text: str) -> str: ...
|
||||
|
||||
_AttributeFilter = Callable[[str, str, str], bool]
|
||||
_AttributeDict = dict[str, list[str] | _AttributeFilter] | dict[str, list[str]] | dict[str, _AttributeFilter]
|
||||
_Attributes = _AttributeFilter | _AttributeDict | list[str]
|
||||
_AttributeFilter: TypeAlias = Callable[[str, str, str], bool]
|
||||
_AttributeDict: TypeAlias = dict[str, list[str] | _AttributeFilter] | dict[str, list[str]] | dict[str, _AttributeFilter]
|
||||
_Attributes: TypeAlias = _AttributeFilter | _AttributeDict | list[str]
|
||||
|
||||
def attribute_filter_factory(attributes: _Attributes) -> _AttributeFilter: ...
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import sys
|
||||
import time
|
||||
from contextlib import AbstractContextManager
|
||||
from typing import IO, Any, Callable, Iterable, Mapping, Sequence, TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
import boto.connection
|
||||
|
||||
@@ -15,28 +16,28 @@ if sys.version_info >= (3,):
|
||||
# TODO move _StringIO definition into boto.compat once stubs exist and rename to StringIO
|
||||
import io
|
||||
|
||||
_StringIO = io.StringIO
|
||||
_StringIO: TypeAlias = io.StringIO
|
||||
|
||||
from hashlib import _Hash
|
||||
|
||||
_HashType = _Hash
|
||||
_HashType: TypeAlias = _Hash
|
||||
|
||||
from email.message import Message as _Message
|
||||
else:
|
||||
# TODO move _StringIO definition into boto.compat once stubs exist and rename to StringIO
|
||||
import StringIO
|
||||
|
||||
_StringIO = StringIO.StringIO[Any]
|
||||
_StringIO: TypeAlias = StringIO.StringIO[Any]
|
||||
|
||||
from hashlib import _hash
|
||||
|
||||
_HashType = _hash
|
||||
_HashType: TypeAlias = _hash
|
||||
|
||||
# TODO use email.message.Message once stubs exist
|
||||
_Message = Any
|
||||
_Message: TypeAlias = Any
|
||||
|
||||
_Provider = Any # TODO replace this with boto.provider.Provider once stubs exist
|
||||
_LockType = Any # TODO replace this with _thread.LockType once stubs exist
|
||||
_Provider: TypeAlias = Any # TODO replace this with boto.provider.Provider once stubs exist
|
||||
_LockType: TypeAlias = Any # TODO replace this with _thread.LockType once stubs exist
|
||||
|
||||
JSONDecodeError: type[ValueError]
|
||||
qsa_of_interest: list[str]
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
from _typeshed import StrOrBytesPath
|
||||
from typing import Any
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_OpenFile = StrOrBytesPath | int
|
||||
_OpenFile: TypeAlias = StrOrBytesPath | int
|
||||
|
||||
def main(template: _OpenFile, data: _OpenFile | None = ..., **kwargs: Any) -> str: ...
|
||||
def cli_main() -> None: ...
|
||||
|
||||
@@ -2,6 +2,7 @@ import sys
|
||||
from _typeshed import SupportsWrite
|
||||
from types import TracebackType
|
||||
from typing import Any, Callable, Pattern, Sequence, TextIO
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.platform == "win32":
|
||||
from .winterm import WinTerm
|
||||
@@ -22,8 +23,8 @@ class StreamWrapper:
|
||||
@property
|
||||
def closed(self) -> bool: ...
|
||||
|
||||
_WinTermCall = Callable[[int | None, bool, bool], None]
|
||||
_WinTermCallDict = dict[int, tuple[_WinTermCall] | tuple[_WinTermCall, int] | tuple[_WinTermCall, int, bool]]
|
||||
_WinTermCall: TypeAlias = Callable[[int | None, bool, bool], None]
|
||||
_WinTermCallDict: TypeAlias = dict[int, tuple[_WinTermCall] | tuple[_WinTermCall, int] | tuple[_WinTermCall, int, bool]]
|
||||
|
||||
class AnsiToWin32:
|
||||
ANSI_CSI_RE: Pattern[str] = ...
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import datetime
|
||||
from _typeshed import Self
|
||||
from typing import Any, Iterator, Text
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
_RetType = type[float | datetime.datetime]
|
||||
_RetType: TypeAlias = type[float | datetime.datetime]
|
||||
|
||||
class CroniterError(ValueError): ...
|
||||
class CroniterBadCronError(CroniterError): ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import datetime
|
||||
from typing_extensions import Literal, TypedDict
|
||||
from typing_extensions import Literal, TypeAlias, TypedDict
|
||||
|
||||
from .date import DateDataParser, _DetectLanguagesFunction
|
||||
|
||||
@@ -7,8 +7,8 @@ __version__: str
|
||||
|
||||
_default_parser: DateDataParser
|
||||
|
||||
_Part = Literal["day", "month", "year"]
|
||||
_ParserKind = Literal["timestamp", "relative-time", "custom-formats", "absolute-time", "no-spaces-time"]
|
||||
_Part: TypeAlias = Literal["day", "month", "year"]
|
||||
_ParserKind: TypeAlias = Literal["timestamp", "relative-time", "custom-formats", "absolute-time", "no-spaces-time"]
|
||||
|
||||
class _Settings(TypedDict, total=False):
|
||||
DATE_ORDER: str
|
||||
|
||||
@@ -3,15 +3,15 @@ from _typeshed import Self as Self
|
||||
from collections.abc import Callable, Iterable, Iterator
|
||||
from datetime import datetime
|
||||
from typing import ClassVar, Pattern, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from dateparser import _Settings
|
||||
from dateparser.conf import Settings
|
||||
from dateparser.languages.loader import LocaleDataLoader
|
||||
from dateparser.languages.locale import Locale
|
||||
|
||||
_DetectLanguagesFunction = Callable[[str, float], list[str]]
|
||||
_Period = Literal["time", "day", "week", "month", "year"]
|
||||
_DetectLanguagesFunction: TypeAlias = Callable[[str, float], list[str]]
|
||||
_Period: TypeAlias = Literal["time", "day", "week", "month", "year"]
|
||||
|
||||
APOSTROPHE_LOOK_ALIKE_CHARS: list[str]
|
||||
RE_NBSP: Pattern[str]
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from typing import Any, Iterable
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__version__: str
|
||||
|
||||
_Argv = Iterable[str] | str
|
||||
_Argv: TypeAlias = Iterable[str] | str
|
||||
|
||||
def docopt(
|
||||
doc: str, argv: _Argv | None = ..., help: bool = ..., version: Any | None = ..., options_first: bool = ...
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
from typing import Any, Callable
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
import docutils.nodes
|
||||
import docutils.parsers.rst.states
|
||||
from docutils.languages import _LanguageModule
|
||||
from docutils.utils import Reporter, SystemMessage
|
||||
|
||||
_RoleFn = Callable[
|
||||
_RoleFn: TypeAlias = Callable[
|
||||
[str, str, str, int, docutils.parsers.rst.states.Inliner, dict[str, Any], list[str]],
|
||||
tuple[list[docutils.nodes.reference], list[docutils.nodes.reference]],
|
||||
]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import optparse
|
||||
from collections.abc import Iterable
|
||||
from typing import Any
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from docutils import ApplicationError
|
||||
from docutils.io import FileOutput
|
||||
@@ -17,7 +17,7 @@ class DependencyList:
|
||||
def add(self, *filenames: str) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
|
||||
_SystemMessageLevel = Literal[0, 1, 2, 3, 4]
|
||||
_SystemMessageLevel: TypeAlias = Literal[0, 1, 2, 3, 4]
|
||||
|
||||
class Reporter:
|
||||
DEBUG_LEVEL: Literal[0]
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import argparse
|
||||
import ast
|
||||
from typing import Any, Generic, Iterable, Iterator, TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
FLAKE8_ERROR = tuple[int, int, str, type[Any]]
|
||||
FLAKE8_ERROR: TypeAlias = tuple[int, int, str, type[Any]]
|
||||
TConfig = TypeVar("TConfig") # noqa: Y001 # Name of the TypeVar matches the name at runtime
|
||||
|
||||
class Error:
|
||||
|
||||
@@ -7,7 +7,7 @@ from enum import IntEnum
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from typing import Any, NamedTuple, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from PIL import Image
|
||||
|
||||
@@ -16,10 +16,10 @@ from .recorder import FPDFRecorder
|
||||
from .syntax import DestinationXYZ
|
||||
from .util import _Unit
|
||||
|
||||
_Orientation = Literal["", "portrait", "p", "P", "landscape", "l", "L"]
|
||||
_Format = Literal["", "a3", "A3", "a4", "A4", "a5", "A5", "letter", "Letter", "legal", "Legal"]
|
||||
_FontStyle = Literal["", "B", "I"]
|
||||
_FontStyles = Literal["", "B", "I", "U", "BU", "UB", "BI", "IB", "IU", "UI", "BIU", "BUI", "IBU", "IUB", "UBI", "UIB"]
|
||||
_Orientation: TypeAlias = Literal["", "portrait", "p", "P", "landscape", "l", "L"]
|
||||
_Format: TypeAlias = Literal["", "a3", "A3", "a4", "A4", "a5", "A5", "letter", "Letter", "legal", "Legal"]
|
||||
_FontStyle: TypeAlias = Literal["", "B", "I"]
|
||||
_FontStyles: TypeAlias = Literal["", "B", "I", "U", "BU", "UB", "BI", "IB", "IU", "UI", "BIU", "BUI", "IBU", "IUB", "UBI", "UIB"]
|
||||
PAGE_FORMATS: dict[_Format, tuple[float, float]]
|
||||
|
||||
class DocumentState(IntEnum):
|
||||
@@ -64,10 +64,10 @@ def get_page_format(format: _Format | tuple[float, float], k: float | None = ...
|
||||
def load_cache(filename: Path): ...
|
||||
|
||||
# TODO: TypedDicts
|
||||
_Page = dict[str, Any]
|
||||
_Font = dict[str, Any]
|
||||
_FontFile = dict[str, Any]
|
||||
_Image = dict[str, Any]
|
||||
_Page: TypeAlias = dict[str, Any]
|
||||
_Font: TypeAlias = dict[str, Any]
|
||||
_FontFile: TypeAlias = dict[str, Any]
|
||||
_Image: TypeAlias = dict[str, Any]
|
||||
|
||||
class FPDF:
|
||||
MARKDOWN_BOLD_MARKER: str
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from typing import Any
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
_ImageFilter = Literal["AUTO", "FlateDecode", "DCTDecode", "JPXDecode"]
|
||||
_ImageFilter: TypeAlias = Literal["AUTO", "FlateDecode", "DCTDecode", "JPXDecode"]
|
||||
|
||||
SUPPORTED_IMAGE_FILTERS: tuple[_ImageFilter, ...]
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from collections.abc import Iterable
|
||||
from typing import Any
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
_Unit = Literal["pt", "mm", "cm", "in"]
|
||||
_Unit: TypeAlias = Literal["pt", "mm", "cm", "in"]
|
||||
|
||||
def substr(s, start, length: int = ...): ...
|
||||
def enclose_in_parens(s): ...
|
||||
|
||||
@@ -2,9 +2,10 @@ from collections.abc import Awaitable, Callable, Iterator, Sequence
|
||||
from datetime import date, datetime, timedelta
|
||||
from numbers import Real
|
||||
from typing import Any, TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_Freezable = str | datetime | date | timedelta
|
||||
_Freezable: TypeAlias = str | datetime | date | timedelta
|
||||
|
||||
class TickingDateTimeFactory:
|
||||
def __init__(self, time_to_freeze: datetime, start: datetime) -> None: ...
|
||||
|
||||
@@ -2,7 +2,7 @@ import datetime
|
||||
from _typeshed import Self
|
||||
from collections.abc import Iterable, Sequence
|
||||
from typing import Any, Callable, NoReturn
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from google.cloud.ndb import exceptions, key as key_module, query as query_module, tasklets as tasklets_module
|
||||
|
||||
@@ -24,7 +24,7 @@ class UserNotFoundError(exceptions.Error): ...
|
||||
class _NotEqualMixin:
|
||||
def __ne__(self, other: object) -> bool: ...
|
||||
|
||||
DirectionT = Literal["asc", "desc"]
|
||||
DirectionT: TypeAlias = Literal["asc", "desc"]
|
||||
|
||||
class IndexProperty(_NotEqualMixin):
|
||||
def __new__(cls: type[Self], name: str, direction: DirectionT) -> Self: ...
|
||||
|
||||
@@ -2,7 +2,7 @@ import decimal
|
||||
from _typeshed import ReadableBuffer
|
||||
from datetime import date, datetime, time
|
||||
from typing import Any, Sequence, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from .resultrow import ResultRow
|
||||
|
||||
@@ -44,7 +44,7 @@ class LOB:
|
||||
def read(self, size: int = ..., position: int = ...) -> str | bytes: ...
|
||||
def write(self, object: str | bytes) -> int: ...
|
||||
|
||||
_Parameters = Sequence[tuple[Any, ...]]
|
||||
_Parameters: TypeAlias = Sequence[tuple[Any, ...]]
|
||||
|
||||
class Cursor:
|
||||
description: tuple[tuple[Any, ...], ...]
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import sys
|
||||
from collections import OrderedDict
|
||||
from typing import Any
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
entitiesTrie: Any
|
||||
if sys.version_info >= (3, 7):
|
||||
attributeMap = dict[Any, Any]
|
||||
attributeMap: TypeAlias = dict[Any, Any]
|
||||
else:
|
||||
attributeMap = OrderedDict[Any, Any]
|
||||
attributeMap: TypeAlias = OrderedDict[Any, Any]
|
||||
|
||||
class HTMLTokenizer:
|
||||
stream: Any
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
from _typeshed import SupportsKeysAndGetItem
|
||||
from collections.abc import Callable, Generator, Iterable
|
||||
from typing import Any, ClassVar, Mapping
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from ._utils import URIDict
|
||||
|
||||
_Schema = Mapping[str, Any]
|
||||
_Schema: TypeAlias = Mapping[str, Any]
|
||||
|
||||
# This class does not exist at runtime. Compatible classes are created at
|
||||
# runtime by create().
|
||||
@@ -43,7 +44,7 @@ class Draft7Validator(_Validator): ...
|
||||
class Draft201909Validator(_Validator): ...
|
||||
class Draft202012Validator(_Validator): ...
|
||||
|
||||
_Handler = Callable[[str], Any]
|
||||
_Handler: TypeAlias = Callable[[str], Any]
|
||||
|
||||
class RefResolver:
|
||||
referrer: dict[str, Any]
|
||||
|
||||
@@ -2,7 +2,7 @@ from _collections_abc import Generator, dict_keys
|
||||
from _typeshed import Self
|
||||
from types import TracebackType
|
||||
from typing import Any
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from .pooling import ServerPool
|
||||
from .server import Server
|
||||
@@ -10,7 +10,9 @@ from .server import Server
|
||||
SASL_AVAILABLE_MECHANISMS: Any
|
||||
CLIENT_STRATEGIES: Any
|
||||
|
||||
_ServerSequence = set[Server] | list[Server] | tuple[Server, ...] | Generator[Server, None, None] | dict_keys[Server, Any]
|
||||
_ServerSequence: TypeAlias = (
|
||||
set[Server] | list[Server] | tuple[Server, ...] | Generator[Server, None, None] | dict_keys[Server, Any]
|
||||
)
|
||||
|
||||
class Connection:
|
||||
connection_lock: Any
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
from threading import Event
|
||||
from typing import Callable
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from paramiko.pkey import PKey
|
||||
from paramiko.ssh_gss import _SSH_GSSAuth
|
||||
from paramiko.transport import Transport
|
||||
|
||||
_InteractiveCallback = Callable[[str, str, list[tuple[str, bool]]], list[str]]
|
||||
_InteractiveCallback: TypeAlias = Callable[[str, str, list[tuple[str, bool]]], list[str]]
|
||||
|
||||
class AuthHandler:
|
||||
transport: Transport
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import sys
|
||||
from typing import Protocol
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
MSG_DISCONNECT: int
|
||||
MSG_IGNORE: int
|
||||
@@ -109,7 +110,7 @@ else:
|
||||
class _SupportsAsBytes(Protocol):
|
||||
def asbytes(self) -> bytes: ...
|
||||
|
||||
_LikeBytes = bytes | str | _SupportsAsBytes
|
||||
_LikeBytes: TypeAlias = bytes | str | _SupportsAsBytes
|
||||
|
||||
def asbytes(s: _LikeBytes) -> bytes: ...
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import sys
|
||||
from typing import Any, Iterable
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from .common import _LikeBytes
|
||||
|
||||
@@ -8,7 +9,7 @@ if sys.version_info >= (3, 0):
|
||||
else:
|
||||
from StringIO import StringIO
|
||||
|
||||
BytesIO = StringIO[bytes]
|
||||
BytesIO: TypeAlias = StringIO[bytes]
|
||||
|
||||
class Message:
|
||||
big_int: int
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from _typeshed import Self
|
||||
from logging import Logger
|
||||
from typing import IO, Any, Callable, Iterator
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from paramiko.channel import Channel
|
||||
from paramiko.sftp import BaseSFTP
|
||||
@@ -9,7 +10,7 @@ from paramiko.sftp_file import SFTPFile
|
||||
from paramiko.transport import Transport
|
||||
from paramiko.util import ClosingContextManager
|
||||
|
||||
_Callback = Callable[[int, int], Any]
|
||||
_Callback: TypeAlias = Callable[[int, int], Any]
|
||||
|
||||
b_slash: bytes
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ from socket import socket
|
||||
from threading import Condition, Event, Lock, Thread
|
||||
from types import ModuleType
|
||||
from typing import Any, Callable, Iterable, Protocol, Sequence
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from paramiko.auth_handler import AuthHandler, _InteractiveCallback
|
||||
from paramiko.channel import Channel
|
||||
@@ -14,8 +15,8 @@ from paramiko.sftp_client import SFTPClient
|
||||
from paramiko.ssh_gss import _SSH_GSSAuth
|
||||
from paramiko.util import ClosingContextManager
|
||||
|
||||
_Addr = tuple[str, int]
|
||||
_SocketLike = str | _Addr | socket | Channel
|
||||
_Addr: TypeAlias = tuple[str, int]
|
||||
_SocketLike: TypeAlias = str | _Addr | socket | Channel
|
||||
|
||||
class _KexEngine(Protocol):
|
||||
def start_kex(self) -> None: ...
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import typing
|
||||
from typing import Any, Callable, Mapping, Pattern, Union
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from parsimonious.exceptions import ParseError
|
||||
from parsimonious.grammar import Grammar
|
||||
@@ -8,8 +9,8 @@ from parsimonious.utils import StrAndRepr
|
||||
|
||||
MARKER: Any
|
||||
|
||||
_CALLABLE_RETURN_TYPE = Union[int, tuple[int, list[Node]], Node, None]
|
||||
_CALLABLE_TYPE = (
|
||||
_CALLABLE_RETURN_TYPE: TypeAlias = Union[int, tuple[int, list[Node]], Node, None]
|
||||
_CALLABLE_TYPE: TypeAlias = (
|
||||
Callable[[str, int], _CALLABLE_RETURN_TYPE]
|
||||
| Callable[[str, int, Mapping[tuple[int, int], Node], ParseError, Grammar], _CALLABLE_RETURN_TYPE]
|
||||
)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
from typing import Any, Callable
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from google.protobuf.descriptor import Descriptor, FieldDescriptor
|
||||
from google.protobuf.message import Message
|
||||
|
||||
_Decoder = Callable[[str, int, int, Message, dict[FieldDescriptor, Any]], int]
|
||||
_NewDefault = Callable[[Message], Message]
|
||||
_Decoder: TypeAlias = Callable[[str, int, int, Message, dict[FieldDescriptor, Any]], int]
|
||||
_NewDefault: TypeAlias = Callable[[Message], Message]
|
||||
|
||||
def ReadTag(buffer, pos): ...
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from typing import Callable
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from google.protobuf.descriptor import FieldDescriptor
|
||||
|
||||
_Sizer = Callable[[int, bool, bool], int]
|
||||
_Sizer: TypeAlias = Callable[[int, bool, bool], int]
|
||||
|
||||
Int32Sizer: _Sizer
|
||||
UInt32Sizer: _Sizer
|
||||
@@ -19,7 +20,7 @@ def MessageSetItemSizer(field_number: int) -> _Sizer: ...
|
||||
def MapSizer(field_descriptor: FieldDescriptor, is_message_map: bool) -> _Sizer: ...
|
||||
def TagBytes(field_number: int, wire_type: int) -> bytes: ...
|
||||
|
||||
_Encoder = Callable[[Callable[[bytes], int], bytes, bool], int]
|
||||
_Encoder: TypeAlias = Callable[[Callable[[bytes], int], bytes, bool], int]
|
||||
|
||||
Int32Encoder: _Encoder
|
||||
UInt32Encoder: _Encoder
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from _typeshed import SupportsWrite
|
||||
from typing import Any, Callable, Iterable, Text, TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from .descriptor import FieldDescriptor
|
||||
from .descriptor_pool import DescriptorPool
|
||||
@@ -20,7 +21,7 @@ class TextWriter:
|
||||
def getvalue(self) -> str: ...
|
||||
def close(self) -> None: ...
|
||||
|
||||
_MessageFormatter = Callable[[Message, int, bool], Text | None]
|
||||
_MessageFormatter: TypeAlias = Callable[[Message, int, bool], Text | None]
|
||||
|
||||
def MessageToString(
|
||||
message: Message,
|
||||
|
||||
@@ -2,7 +2,7 @@ import enum
|
||||
from _typeshed import StrOrBytesPath, SupportsWrite
|
||||
from socket import AddressFamily, SocketKind
|
||||
from typing import Any, Callable, NamedTuple, TypeVar, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
POSIX: bool
|
||||
WINDOWS: bool
|
||||
@@ -31,7 +31,7 @@ STATUS_WAITING: Literal["waiting"]
|
||||
STATUS_SUSPENDED: Literal["suspended"]
|
||||
STATUS_PARKED: Literal["parked"]
|
||||
|
||||
_Status = Literal[
|
||||
_Status: TypeAlias = Literal[
|
||||
"running",
|
||||
"sleeping",
|
||||
"disk-sleep",
|
||||
|
||||
@@ -2,12 +2,13 @@ from _typeshed import Self
|
||||
from collections.abc import Callable, Iterable, Mapping, Sequence
|
||||
from types import TracebackType
|
||||
from typing import Any, TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
import psycopg2
|
||||
import psycopg2.extensions
|
||||
from psycopg2.sql import Composable
|
||||
|
||||
_Vars = Sequence[Any] | Mapping[str, Any] | None
|
||||
_Vars: TypeAlias = Sequence[Any] | Mapping[str, Any] | None
|
||||
|
||||
BINARY: Any
|
||||
BINARYARRAY: Any
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
from _typeshed import StrOrBytesPath
|
||||
from datetime import datetime
|
||||
from typing import Any, Callable, Iterable, Sequence
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKey, DSAPublicKey
|
||||
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey
|
||||
from cryptography.x509 import Certificate, CertificateRevocationList, CertificateSigningRequest
|
||||
|
||||
_Key = DSAPrivateKey | DSAPublicKey | RSAPrivateKey | RSAPublicKey
|
||||
_Key: TypeAlias = DSAPrivateKey | DSAPublicKey | RSAPrivateKey | RSAPublicKey
|
||||
|
||||
FILETYPE_PEM: int
|
||||
FILETYPE_ASN1: int
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from typing import Callable, Mapping, Sequence
|
||||
from typing_extensions import Final
|
||||
from typing_extensions import Final, TypeAlias
|
||||
|
||||
paFloat32: Final[int]
|
||||
paInt32: Final[int]
|
||||
@@ -67,10 +67,10 @@ paPrimingOutput: Final[int]
|
||||
paMacCoreStreamInfo: PaMacCoreStreamInfo
|
||||
|
||||
# Auxiliary types
|
||||
_ChannelMap = Sequence[int]
|
||||
_PaHostApiInfo = Mapping[str, str | int]
|
||||
_PaDeviceInfo = Mapping[str, str | int | float]
|
||||
_StreamCallback = Callable[[bytes | None, int, Mapping[str, float], int], tuple[bytes | None, int]]
|
||||
_ChannelMap: TypeAlias = Sequence[int]
|
||||
_PaHostApiInfo: TypeAlias = Mapping[str, str | int]
|
||||
_PaDeviceInfo: TypeAlias = Mapping[str, str | int | float]
|
||||
_StreamCallback: TypeAlias = Callable[[bytes | None, int, Mapping[str, float], int], tuple[bytes | None, int]]
|
||||
|
||||
def get_format_from_width(width: int, unsigned: bool = ...) -> int: ...
|
||||
def get_portaudio_version() -> int: ...
|
||||
|
||||
@@ -3,11 +3,11 @@ import sys
|
||||
from collections.abc import Callable, Iterable, Iterator
|
||||
from tokenize import TokenInfo
|
||||
from typing import Any, ClassVar, Pattern, TypeVar, overload
|
||||
from typing_extensions import Literal, ParamSpec
|
||||
from typing_extensions import Literal, ParamSpec, TypeAlias
|
||||
|
||||
from pyflakes.messages import Message
|
||||
|
||||
_AnyFunction = Callable[..., Any]
|
||||
_AnyFunction: TypeAlias = Callable[..., Any]
|
||||
_F = TypeVar("_F", bound=_AnyFunction)
|
||||
_P = ParamSpec("_P")
|
||||
_T = TypeVar("_T")
|
||||
@@ -37,8 +37,8 @@ PRECISION_RE: Pattern[str]
|
||||
LENGTH_RE: Pattern[str]
|
||||
VALID_CONVERSIONS: frozenset[str]
|
||||
|
||||
_FormatType = tuple[str | None, str | None, str | None, str | None, str]
|
||||
_PercentFormat = tuple[str, _FormatType | None]
|
||||
_FormatType: TypeAlias = tuple[str | None, str | None, str | None, str | None, str]
|
||||
_PercentFormat: TypeAlias = tuple[str, _FormatType | None]
|
||||
|
||||
def parse_percent_format(s: str) -> tuple[_PercentFormat, ...]: ...
|
||||
|
||||
@@ -47,7 +47,7 @@ class _FieldsOrder(dict[type[ast.AST], tuple[str, ...]]):
|
||||
|
||||
def counter(items: Iterable[_T]) -> dict[_T, int]: ...
|
||||
|
||||
_OmitType = str | tuple[str, ...] | None
|
||||
_OmitType: TypeAlias = str | tuple[str, ...] | None
|
||||
|
||||
def iter_child_nodes(node: ast.AST, omit: _OmitType = ..., _fields_order: _FieldsOrder = ...) -> Iterator[ast.AST]: ...
|
||||
@overload
|
||||
|
||||
@@ -3,7 +3,7 @@ from contextlib import AbstractContextManager
|
||||
from stat import S_IMODE as S_IMODE
|
||||
from types import TracebackType
|
||||
from typing import IO, Any, Callable, Sequence
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
import paramiko
|
||||
from paramiko import AuthenticationException as AuthenticationException
|
||||
@@ -32,8 +32,8 @@ class CnOpts:
|
||||
def __init__(self, knownhosts: str | None = ...) -> None: ...
|
||||
def get_hostkey(self, host: str) -> paramiko.PKey: ...
|
||||
|
||||
_Callback = Callable[[int, int], Any]
|
||||
_Path = str | bytes
|
||||
_Callback: TypeAlias = Callable[[int, int], Any]
|
||||
_Path: TypeAlias = str | bytes
|
||||
|
||||
class Connection:
|
||||
def __init__(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from collections.abc import Callable, Iterator
|
||||
from contextlib import AbstractContextManager
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
def known_hosts() -> str: ...
|
||||
def st_mode_to_int(val: int) -> int: ...
|
||||
@@ -26,7 +27,7 @@ def path_advance(thepath: str, sep: str = ...) -> Iterator[str]: ...
|
||||
def path_retreat(thepath: str, sep: str = ...) -> Iterator[str]: ...
|
||||
def reparent(newparent: str, oldpath: str) -> str: ...
|
||||
|
||||
_PathCallback = Callable[[str], None]
|
||||
_PathCallback: TypeAlias = Callable[[str], None]
|
||||
|
||||
def walktree(
|
||||
localpath: str, fcallback: _PathCallback, dcallback: _PathCallback, ucallback: _PathCallback, recurse: bool = ...
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
from datetime import datetime, tzinfo
|
||||
from typing import IO, Any, Mapping, Text
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from .isoparser import isoparse as isoparse, isoparser as isoparser
|
||||
|
||||
_FileOrStr = bytes | Text | IO[str] | IO[Any]
|
||||
_FileOrStr: TypeAlias = bytes | Text | IO[str] | IO[Any]
|
||||
|
||||
class parserinfo(object):
|
||||
JUMP: list[str]
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
from _typeshed import SupportsRead
|
||||
from datetime import date, datetime, time, tzinfo
|
||||
from typing import Text
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_Readable = SupportsRead[Text | bytes]
|
||||
_TakesAscii = Text | bytes | _Readable
|
||||
_Readable: TypeAlias = SupportsRead[Text | bytes]
|
||||
_TakesAscii: TypeAlias = Text | bytes | _Readable
|
||||
|
||||
class isoparser:
|
||||
def __init__(self, sep: Text | bytes | None = ...): ...
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import datetime
|
||||
from typing import IO, Any, Text, TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from ..relativedelta import relativedelta
|
||||
from ._common import _tzinfo as _tzinfo, enfold as enfold, tzname_in_python2 as tzname_in_python2, tzrangebase as tzrangebase
|
||||
|
||||
_FileObj = str | Text | IO[str] | IO[Text]
|
||||
_FileObj: TypeAlias = str | Text | IO[str] | IO[Text]
|
||||
_DT = TypeVar("_DT", bound=datetime.datetime)
|
||||
|
||||
ZERO: datetime.timedelta
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from typing import Any, Callable, Iterable, Iterator, Text, TypeVar
|
||||
from typing_extensions import TypedDict
|
||||
from typing_extensions import TypeAlias, TypedDict
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_Callback = Callable[[str, _Result], Any]
|
||||
_Callback: TypeAlias = Callable[[str, _Result], Any]
|
||||
|
||||
class _Result(TypedDict):
|
||||
nmap: _ResultNmap
|
||||
|
||||
@@ -3,15 +3,15 @@ from _typeshed import Self, SupportsItems
|
||||
from datetime import datetime, timedelta
|
||||
from types import TracebackType
|
||||
from typing import Any, Callable, ClassVar, Generic, Iterable, Iterator, Mapping, Pattern, Sequence, TypeVar, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from .commands import CoreCommands, RedisModuleCommands, SentinelCommands
|
||||
from .connection import ConnectionPool, _ConnectionPoolOptions
|
||||
from .lock import Lock
|
||||
from .retry import Retry
|
||||
|
||||
_Value = bytes | float | int | str
|
||||
_Key = str | bytes
|
||||
_Value: TypeAlias = bytes | float | int | str
|
||||
_Key: TypeAlias = str | bytes
|
||||
|
||||
# Lib returns str or bytes depending on value of decode_responses
|
||||
_StrType = TypeVar("_StrType", bound=str | bytes)
|
||||
@@ -21,9 +21,9 @@ _T = TypeVar("_T")
|
||||
_ScoreCastFuncReturn = TypeVar("_ScoreCastFuncReturn")
|
||||
|
||||
# Keyword arguments that are passed to Redis.parse_response().
|
||||
_ParseResponseOptions = Any
|
||||
_ParseResponseOptions: TypeAlias = Any
|
||||
# Keyword arguments that are passed to Redis.execute_command().
|
||||
_CommandOptions = _ConnectionPoolOptions | _ParseResponseOptions
|
||||
_CommandOptions: TypeAlias = _ConnectionPoolOptions | _ParseResponseOptions
|
||||
|
||||
SYM_EMPTY: bytes
|
||||
EMPTY_RESPONSE: str
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import Any
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from .aggregation import AggregateRequest, AggregateResult, Cursor
|
||||
from .query import Query
|
||||
from .result import Result
|
||||
|
||||
_QueryParams = Mapping[str, str | float]
|
||||
_QueryParams: TypeAlias = Mapping[str, str | float]
|
||||
|
||||
NUMERIC: Literal["NUMERIC"]
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from _typeshed import Self, SupportsItems
|
||||
from typing import IO, Any, Callable, Iterable, Mapping, MutableMapping, TypeVar, Union
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from urllib3 import _collections
|
||||
|
||||
@@ -27,8 +28,8 @@ TooManyRedirects = exceptions.TooManyRedirects
|
||||
InvalidSchema = exceptions.InvalidSchema
|
||||
ChunkedEncodingError = exceptions.ChunkedEncodingError
|
||||
ContentDecodingError = exceptions.ContentDecodingError
|
||||
RecentlyUsedContainer = _collections.RecentlyUsedContainer[_KT, _VT]
|
||||
CaseInsensitiveDict = structures.CaseInsensitiveDict[_VT]
|
||||
RecentlyUsedContainer: TypeAlias = _collections.RecentlyUsedContainer[_KT, _VT]
|
||||
CaseInsensitiveDict: TypeAlias = structures.CaseInsensitiveDict[_VT]
|
||||
HTTPAdapter = adapters.HTTPAdapter
|
||||
requote_uri = utils.requote_uri
|
||||
get_environ_proxies = utils.get_environ_proxies
|
||||
@@ -47,21 +48,21 @@ class SessionRedirectMixin:
|
||||
def rebuild_proxies(self, prepared_request, proxies): ...
|
||||
def should_strip_auth(self, old_url, new_url): ...
|
||||
|
||||
_Data = str | bytes | Mapping[str, Any] | Iterable[tuple[str, str | None]] | IO[Any] | None
|
||||
_Data: TypeAlias = str | bytes | Mapping[str, Any] | Iterable[tuple[str, str | None]] | IO[Any] | None
|
||||
|
||||
_Hook = Callable[[Response], Any]
|
||||
_Hooks = MutableMapping[str, _Hook | list[_Hook]]
|
||||
_HooksInput = MutableMapping[str, Iterable[_Hook] | _Hook]
|
||||
_Hook: TypeAlias = Callable[[Response], Any]
|
||||
_Hooks: TypeAlias = MutableMapping[str, _Hook | list[_Hook]]
|
||||
_HooksInput: TypeAlias = MutableMapping[str, Iterable[_Hook] | _Hook]
|
||||
|
||||
_ParamsMappingKeyType = str | bytes | int | float
|
||||
_ParamsMappingValueType = str | bytes | int | float | Iterable[str | bytes | int | float] | None
|
||||
_Params = Union[
|
||||
_ParamsMappingKeyType: TypeAlias = str | bytes | int | float
|
||||
_ParamsMappingValueType: TypeAlias = str | bytes | int | float | Iterable[str | bytes | int | float] | None
|
||||
_Params: TypeAlias = Union[
|
||||
SupportsItems[_ParamsMappingKeyType, _ParamsMappingValueType],
|
||||
tuple[_ParamsMappingKeyType, _ParamsMappingValueType],
|
||||
Iterable[tuple[_ParamsMappingKeyType, _ParamsMappingValueType]],
|
||||
str | bytes,
|
||||
]
|
||||
_TextMapping = MutableMapping[str, str]
|
||||
_TextMapping: TypeAlias = MutableMapping[str, str]
|
||||
|
||||
class Session(SessionRedirectMixin):
|
||||
__attrs__: Any
|
||||
|
||||
@@ -4,18 +4,19 @@ import zipimport
|
||||
from _typeshed import Self
|
||||
from abc import ABCMeta
|
||||
from typing import IO, Any, Callable, Generator, Iterable, Sequence, TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
LegacyVersion = Any # from packaging.version
|
||||
Version = Any # from packaging.version
|
||||
LegacyVersion: TypeAlias = Any # from packaging.version
|
||||
Version: TypeAlias = Any # from packaging.version
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_NestedStr = str | Iterable[str | Iterable[Any]]
|
||||
_InstallerType = Callable[[Requirement], Distribution | None]
|
||||
_EPDistType = Distribution | Requirement | str
|
||||
_MetadataType = IResourceProvider | None
|
||||
_PkgReqType = str | Requirement
|
||||
_DistFinderType = Callable[[_Importer, str, bool], Generator[Distribution, None, None]]
|
||||
_NSHandlerType = Callable[[_Importer, str, str, types.ModuleType], str]
|
||||
_NestedStr: TypeAlias = str | Iterable[str | Iterable[Any]]
|
||||
_InstallerType: TypeAlias = Callable[[Requirement], Distribution | None]
|
||||
_EPDistType: TypeAlias = Distribution | Requirement | str
|
||||
_MetadataType: TypeAlias = IResourceProvider | None
|
||||
_PkgReqType: TypeAlias = str | Requirement
|
||||
_DistFinderType: TypeAlias = Callable[[_Importer, str, bool], Generator[Distribution, None, None]]
|
||||
_NSHandlerType: TypeAlias = Callable[[_Importer, str, str, types.ModuleType], str]
|
||||
|
||||
def declare_namespace(name: str) -> None: ...
|
||||
def fixup_namespace_packages(path_item: str) -> None: ...
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
from typing import IO, Any, Text
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from simplejson.decoder import JSONDecoder as JSONDecoder
|
||||
from simplejson.encoder import JSONEncoder as JSONEncoder, JSONEncoderForHTML as JSONEncoderForHTML
|
||||
from simplejson.raw_json import RawJSON as RawJSON
|
||||
from simplejson.scanner import JSONDecodeError as JSONDecodeError
|
||||
|
||||
_LoadsString = Text | bytes | bytearray
|
||||
_LoadsString: TypeAlias = Text | bytes | bytearray
|
||||
|
||||
def dumps(obj: Any, *args: Any, **kwds: Any) -> str: ...
|
||||
def dump(obj: Any, fp: IO[str], *args: Any, **kwds: Any) -> None: ...
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from typing import Any, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from stripe.stripe_object import StripeObject
|
||||
from stripe.stripe_response import StripeResponse
|
||||
@@ -21,7 +22,7 @@ def populate_headers(idempotency_key: None) -> None: ...
|
||||
@overload
|
||||
def populate_headers(idempotency_key: str) -> dict[str, str]: ...
|
||||
|
||||
_RespType = dict[Any, Any] | StripeObject | StripeResponse
|
||||
_RespType: TypeAlias = dict[Any, Any] | StripeObject | StripeResponse
|
||||
|
||||
# undocumented
|
||||
@overload
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from typing import Any, Callable, Container, Iterable, Mapping, NamedTuple, Sequence
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
LATEX_ESCAPE_RULES: dict[str, str]
|
||||
MIN_PADDING: int
|
||||
@@ -18,8 +19,8 @@ class DataRow(NamedTuple):
|
||||
sep: str
|
||||
end: str
|
||||
|
||||
_TableFormatLine = None | Line | Callable[[list[int], list[str]], str]
|
||||
_TableFormatRow = None | DataRow | Callable[[list[Any], list[int], list[str]], str]
|
||||
_TableFormatLine: TypeAlias = None | Line | Callable[[list[int], list[str]], str]
|
||||
_TableFormatRow: TypeAlias = None | DataRow | Callable[[list[Any], list[int], list[str]], str]
|
||||
|
||||
class TableFormat(NamedTuple):
|
||||
lineabove: _TableFormatLine
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import sys
|
||||
from _typeshed import SupportsRead
|
||||
from typing import Any, Callable, Generic, MutableMapping, Pattern, Text, TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_MutableMappingT = TypeVar("_MutableMappingT", bound=MutableMapping[str, Any])
|
||||
|
||||
@@ -8,10 +9,10 @@ if sys.version_info >= (3, 0):
|
||||
from pathlib import PurePath
|
||||
|
||||
FNFError = FileNotFoundError
|
||||
_PathLike = str | bytes | PurePath
|
||||
_PathLike: TypeAlias = str | bytes | PurePath
|
||||
else:
|
||||
FNFError = IOError
|
||||
_PathLike = Text
|
||||
_PathLike: TypeAlias = Text
|
||||
|
||||
TIME_RE: Pattern[str]
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import ssl
|
||||
import sys
|
||||
from typing import IO, Any, Iterable
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from . import exceptions, util
|
||||
from .packages import ssl_match_hostname
|
||||
@@ -14,7 +15,7 @@ else:
|
||||
|
||||
class ConnectionError(Exception): ...
|
||||
|
||||
_TYPE_BODY = bytes | IO[Any] | Iterable[bytes] | str
|
||||
_TYPE_BODY: TypeAlias = bytes | IO[Any] | Iterable[bytes] | str
|
||||
|
||||
class DummyConnection: ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user