Reduce use of deprecated typing aliases (#6358)

This commit is contained in:
Alex Waygood
2021-11-23 09:56:43 +00:00
committed by GitHub
parent 7e836db2f3
commit c685c2d6c6
19 changed files with 64 additions and 61 deletions

View File

@@ -3,7 +3,7 @@ from typing_extensions import TypedDict
from pygments.token import _TokenType
ansicolors: Set[str] # not intended to be mutable
ansicolors: Set[str] # not intended to be mutable (== typing.AbstractSet, not builtins.set)
class _StyleDict(TypedDict):
color: str | None

View File

@@ -1,5 +1,5 @@
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
from typing import Any, Iterable, Mapping, Set, Text
from typing import Any, Iterable, Mapping, Text
from ..middleware.proxy_fix import ProxyFix as ProxyFix
@@ -18,7 +18,7 @@ class PathInfoFromRequestUriFix(object):
class HeaderRewriterFix(object):
app: WSGIApplication
remove_headers: Set[Text]
remove_headers: set[Text]
add_headers: list[Text]
def __init__(
self, app: WSGIApplication, remove_headers: Iterable[Text] | None = ..., add_headers: Iterable[Text] | None = ...

View File

@@ -1,6 +1,6 @@
from _typeshed import Self
from collections.abc import Iterator
from typing import Any, Callable, Generic, Iterable, List, Mapping, Pattern, Set, Tuple, Type, TypeVar, Union, overload
from typing import Any, Callable, Generic, Iterable, List, Mapping, Pattern, Tuple, Type, TypeVar, Union, overload
from . import BeautifulSoup
from .builder import TreeBuilder
@@ -10,7 +10,7 @@ DEFAULT_OUTPUT_ENCODING: str
PY3K: bool
nonwhitespace_re: Pattern[str]
whitespace_re: Pattern[str]
PYTHON_SPECIFIC_ENCODINGS: Set[str]
PYTHON_SPECIFIC_ENCODINGS: set[str]
class NamespacedAttribute(str):
def __new__(cls: Type[Self], prefix: str, name: str | None = ..., namespace: str | None = ...) -> Self: ...

View File

@@ -1,6 +1,7 @@
from _typeshed import IdentityFunction
from collections.abc import Iterator, Sequence
from typing import Any, Callable, ContextManager, Generic, MutableMapping, TypeVar, overload
from contextlib import AbstractContextManager
from typing import Any, Callable, Generic, MutableMapping, TypeVar, overload
_KT = TypeVar("_KT")
_VT = TypeVar("_VT")
@@ -57,10 +58,10 @@ class TTLCache(Cache[_KT, _VT]):
def expire(self, time: float | None = ...) -> None: ...
def cached(
cache: MutableMapping[_KT, Any] | None, key: Callable[..., _KT] = ..., lock: ContextManager[Any] | None = ...
cache: MutableMapping[_KT, Any] | None, key: Callable[..., _KT] = ..., lock: AbstractContextManager[Any] | None = ...
) -> IdentityFunction: ...
def cachedmethod(
cache: Callable[[Any], MutableMapping[_KT, Any] | None],
key: Callable[..., _KT] = ...,
lock: Callable[[Any], ContextManager[Any]] | None = ...,
lock: Callable[[Any], AbstractContextManager[Any]] | None = ...,
) -> IdentityFunction: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, ContextManager, Iterable, Mapping, NoReturn, Optional, Sequence, Set, Tuple, TypeVar, Union
from typing import Any, Callable, ContextManager, Iterable, Mapping, NoReturn, Optional, Sequence, Tuple, TypeVar, Union
from click.formatting import HelpFormatter
from click.parser import OptionParser
@@ -125,7 +125,7 @@ class Command(BaseCommand):
def get_params(self, ctx: Context) -> list[Parameter]: ...
def format_usage(self, ctx: Context, formatter: HelpFormatter) -> None: ...
def collect_usage_pieces(self, ctx: Context) -> list[str]: ...
def get_help_option_names(self, ctx: Context) -> Set[str]: ...
def get_help_option_names(self, ctx: Context) -> set[str]: ...
def get_help_option(self, ctx: Context) -> Option | None: ...
def make_parser(self, ctx: Context) -> OptionParser: ...
def get_short_help_str(self, limit: int = ...) -> str: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Iterable, Set, Tuple
from typing import Any, Iterable, Tuple
from click.core import Context
@@ -13,7 +13,7 @@ class Option:
nargs: int
const: Any
obj: Any
prefixes: Set[str]
prefixes: set[str]
_short_opts: list[str]
_long_opts: list[str]
def __init__(
@@ -49,7 +49,7 @@ class OptionParser:
ignore_unknown_options: bool
_short_opt: dict[str, Option]
_long_opt: dict[str, Option]
_opt_prefixes: Set[str]
_opt_prefixes: set[str]
_args: list[Argument]
def __init__(self, ctx: Context | None = ...) -> None: ...
def add_option(

View File

@@ -1,5 +1,3 @@
from typing import FrozenSet
from cryptography.hazmat.primitives.ciphers import BlockCipherAlgorithm, CipherAlgorithm
from cryptography.hazmat.primitives.ciphers.modes import ModeWithNonce
@@ -7,7 +5,7 @@ class AES(BlockCipherAlgorithm, CipherAlgorithm):
def __init__(self, key: bytes) -> None: ...
block_size: int = ...
name: str = ...
key_sizes: FrozenSet[int] = ...
key_sizes: frozenset[int] = ...
@property
def key_size(self) -> int: ...
@@ -16,7 +14,7 @@ class ARC4(CipherAlgorithm):
@property
def key_size(self) -> int: ...
name: str = ...
key_sizes: FrozenSet[int] = ...
key_sizes: frozenset[int] = ...
class Blowfish(BlockCipherAlgorithm, CipherAlgorithm):
def __init__(self, key: bytes) -> None: ...
@@ -24,7 +22,7 @@ class Blowfish(BlockCipherAlgorithm, CipherAlgorithm):
def key_size(self) -> int: ...
block_size: int = ...
name: str = ...
key_sizes: FrozenSet[int] = ...
key_sizes: frozenset[int] = ...
class Camellia(BlockCipherAlgorithm, CipherAlgorithm):
def __init__(self, key: bytes) -> None: ...
@@ -32,7 +30,7 @@ class Camellia(BlockCipherAlgorithm, CipherAlgorithm):
def key_size(self) -> int: ...
block_size: int = ...
name: str = ...
key_sizes: FrozenSet[int] = ...
key_sizes: frozenset[int] = ...
class CAST5(BlockCipherAlgorithm, CipherAlgorithm):
def __init__(self, key: bytes) -> None: ...
@@ -40,14 +38,14 @@ class CAST5(BlockCipherAlgorithm, CipherAlgorithm):
def key_size(self) -> int: ...
block_size: int = ...
name: str = ...
key_sizes: FrozenSet[int] = ...
key_sizes: frozenset[int] = ...
class ChaCha20(CipherAlgorithm, ModeWithNonce):
def __init__(self, key: bytes, nonce: bytes) -> None: ...
@property
def key_size(self) -> int: ...
name: str = ...
key_sizes: FrozenSet[int] = ...
key_sizes: frozenset[int] = ...
@property
def nonce(self) -> bytes: ...
@@ -57,7 +55,7 @@ class IDEA(CipherAlgorithm):
def key_size(self) -> int: ...
block_size: int = ...
name: str = ...
key_sizes: FrozenSet[int] = ...
key_sizes: frozenset[int] = ...
class SEED(BlockCipherAlgorithm, CipherAlgorithm):
def __init__(self, key: bytes) -> None: ...
@@ -65,7 +63,7 @@ class SEED(BlockCipherAlgorithm, CipherAlgorithm):
def key_size(self) -> int: ...
block_size: int = ...
name: str = ...
key_sizes: FrozenSet[int] = ...
key_sizes: frozenset[int] = ...
class TripleDES(BlockCipherAlgorithm, CipherAlgorithm):
def __init__(self, key: bytes) -> None: ...
@@ -73,4 +71,4 @@ class TripleDES(BlockCipherAlgorithm, CipherAlgorithm):
def key_size(self) -> int: ...
block_size: int = ...
name: str = ...
key_sizes: FrozenSet[int] = ...
key_sizes: frozenset[int] = ...

View File

@@ -1,6 +1,5 @@
import datetime
import sys
from typing import Set
from dateparser.date import DateDataParser
@@ -34,9 +33,9 @@ class _Settings(TypedDict, total=False):
def parse(
date_string: str,
date_formats: list[str] | tuple[str] | Set[str] | None = ...,
languages: list[str] | tuple[str] | Set[str] | None = ...,
locales: list[str] | tuple[str] | Set[str] | None = ...,
date_formats: list[str] | tuple[str] | set[str] | None = ...,
languages: list[str] | tuple[str] | set[str] | None = ...,
locales: list[str] | tuple[str] | set[str] | None = ...,
region: str | None = ...,
settings: _Settings | None = ...,
) -> datetime.datetime | None: ...

View File

@@ -1,4 +1,4 @@
from typing import IO, Any, Dict, Iterable, Pattern, Set
from typing import IO, Any, Dict, Iterable, Pattern
from paramiko.ssh_exception import ConfigParseError as ConfigParseError, CouldNotCanonicalize as CouldNotCanonicalize
@@ -17,7 +17,7 @@ class SSHConfig:
def parse(self, file_obj: IO[str]) -> None: ...
def lookup(self, hostname: str) -> SSHConfigDict: ...
def canonicalize(self, hostname: str, options: SSHConfigDict, domains: Iterable[str]) -> str: ...
def get_hostnames(self) -> Set[str]: ...
def get_hostnames(self) -> set[str]: ...
class LazyFqdn:
fqdn: str | None

View File

@@ -1,5 +1,6 @@
import sys
from typing import Any, Callable, ContextManager, Iterable, Iterator, Tuple, TypeVar
from contextlib import AbstractContextManager
from typing import Any, Callable, Iterable, Iterator, Tuple, TypeVar
from ._common import (
AIX as AIX,
@@ -122,7 +123,7 @@ class Process:
def __hash__(self) -> int: ...
@property
def pid(self) -> int: ...
def oneshot(self) -> ContextManager[None]: ...
def oneshot(self) -> AbstractContextManager[None]: ...
def as_dict(
self, attrs: list[str] | Tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ...
) -> dict[str, Any]: ...

View File

@@ -1,4 +1,5 @@
from typing import Any, ContextManager, NamedTuple
from contextlib import AbstractContextManager
from typing import Any, NamedTuple
from ._common import (
FREEBSD as FREEBSD,
@@ -109,7 +110,7 @@ def pids(): ...
def pid_exists(pid): ...
def is_zombie(pid): ...
def wrap_exceptions(fun): ...
def wrap_exceptions_procfs(inst) -> ContextManager[None]: ...
def wrap_exceptions_procfs(inst) -> AbstractContextManager[None]: ...
class Process:
pid: Any

View File

@@ -1,4 +1,5 @@
from typing import Any, ContextManager, NamedTuple
from contextlib import AbstractContextManager
from typing import Any, NamedTuple
from ._common import (
AccessDenied as AccessDenied,
@@ -71,7 +72,7 @@ pid_exists: Any
def is_zombie(pid): ...
def wrap_exceptions(fun): ...
def catch_zombie(proc) -> ContextManager[None]: ...
def catch_zombie(proc) -> AbstractContextManager[None]: ...
class Process:
pid: Any

View File

@@ -1,5 +1,5 @@
from datetime import datetime
from typing import Any, Callable, Iterable, Sequence, Set, Text, Tuple, Union
from typing import Any, Callable, Iterable, Sequence, Text, Tuple, Union
from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKey, DSAPublicKey
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey
@@ -183,7 +183,7 @@ class NetscapeSPKI:
def sign(self, pkey: PKey, digest: bytes) -> None: ...
def verify(self, key: PKey) -> bool: ...
def get_elliptic_curves() -> Set[_EllipticCurve]: ...
def get_elliptic_curves() -> set[_EllipticCurve]: ...
def get_elliptic_curve(name: Text) -> _EllipticCurve: ...
def dump_certificate(type: int, cert: X509) -> bytes: ...
def load_certificate(type: int, buffer: bytes) -> X509: ...

View File

@@ -1,5 +1,5 @@
import datetime
from typing import Mapping, Set
from typing import Mapping
class BaseTzInfo(datetime.tzinfo):
zone: str = ...
@@ -33,9 +33,9 @@ def timezone(zone: str) -> _UTCclass | _StaticTzInfo | _DstTzInfo: ...
def FixedOffset(offset: int) -> _UTCclass | datetime.tzinfo: ...
all_timezones: list[str]
all_timezones_set: Set[str]
all_timezones_set: set[str]
common_timezones: list[str]
common_timezones_set: Set[str]
common_timezones_set: set[str]
country_timezones: Mapping[str, list[str]]
country_names: Mapping[str, str]
ZERO: datetime.timedelta

View File

@@ -1,5 +1,6 @@
import builtins
from datetime import datetime, timedelta
from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, Sequence, Set, Text, Type, TypeVar, Union, overload
from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, Sequence, Text, Type, TypeVar, Union, overload
from typing_extensions import Literal
from .connection import ConnectionPool
@@ -569,12 +570,12 @@ class Redis(Generic[_StrType]):
def zscan_iter(self, name, match=..., count=..., score_cast_func=...): ...
def sadd(self, name: _Key, *values: _Value) -> int: ...
def scard(self, name: _Key) -> int: ...
def sdiff(self, keys: _Key | Iterable[_Key], *args: _Key) -> Set[_Value]: ...
def sdiff(self, keys: _Key | Iterable[_Key], *args: _Key) -> builtins.set[_Value]: ...
def sdiffstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> int: ...
def sinter(self, keys: _Key | Iterable[_Key], *args: _Key) -> Set[_Value]: ...
def sinter(self, keys: _Key | Iterable[_Key], *args: _Key) -> builtins.set[_Value]: ...
def sinterstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> int: ...
def sismember(self, name: _Key, value: _Value) -> bool: ...
def smembers(self, name: _Key) -> Set[_StrType]: ...
def smembers(self, name: _Key) -> builtins.set[_StrType]: ...
def smove(self, src: _Key, dst: _Key, value: _Value) -> bool: ...
@overload
def spop(self, name: _Key, count: None = ...) -> _Value | None: ...
@@ -585,7 +586,7 @@ class Redis(Generic[_StrType]):
@overload
def srandmember(self, name: _Key, number: int) -> list[_Value]: ...
def srem(self, name: _Key, *values: _Value) -> int: ...
def sunion(self, keys: _Key | Iterable[_Key], *args: _Key) -> Set[_Value]: ...
def sunion(self, keys: _Key | Iterable[_Key], *args: _Key) -> builtins.set[_Value]: ...
def sunionstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> int: ...
def xack(self, name, groupname, *ids): ...
def xadd(self, name, fields, id=..., maxlen=..., approximate=...): ...

View File

@@ -2,7 +2,7 @@ import importlib.abc
import types
import zipimport
from abc import ABCMeta
from typing import IO, Any, Callable, Generator, Iterable, Optional, Sequence, Set, Tuple, TypeVar, Union, overload
from typing import IO, Any, Callable, Generator, Iterable, Optional, Sequence, Tuple, TypeVar, Union, overload
LegacyVersion = Any # from packaging.version
Version = Any # from packaging.version
@@ -203,7 +203,7 @@ class DistributionNotFound(ResolutionError):
@property
def req(self) -> Requirement: ...
@property
def requirers(self) -> Set[str]: ...
def requirers(self) -> set[str]: ...
@property
def requirers_str(self) -> str: ...
def report(self) -> str: ...
@@ -214,11 +214,11 @@ class VersionConflict(ResolutionError):
@property
def req(self) -> Any: ...
def report(self) -> str: ...
def with_context(self, required_by: Set[Distribution | str]) -> VersionConflict: ...
def with_context(self, required_by: set[Distribution | str]) -> VersionConflict: ...
class ContextualVersionConflict(VersionConflict):
@property
def required_by(self) -> Set[Distribution | str]: ...
def required_by(self) -> set[Distribution | str]: ...
class UnknownExtra(ResolutionError): ...

View File

@@ -1,17 +1,17 @@
from socket import socket
from typing import Any, FrozenSet, Iterable, Sequence, Set
from typing import Any, Iterable, Sequence
from .compat import HAS_IPV6 as HAS_IPV6, PY2 as PY2, WIN as WIN, string_types as string_types
from .proxy_headers import PROXY_HEADERS as PROXY_HEADERS
truthy: FrozenSet[Any]
KNOWN_PROXY_HEADERS: FrozenSet[Any]
truthy: frozenset[Any]
KNOWN_PROXY_HEADERS: frozenset[Any]
def asbool(s: bool | str | int | None) -> bool: ...
def asoctal(s: str) -> int: ...
def aslist_cronly(value: str) -> list[str]: ...
def aslist(value: str) -> list[str]: ...
def asset(value: str | None) -> Set[str]: ...
def asset(value: str | None) -> set[str]: ...
def slash_fixed_str(s: str | None) -> str: ...
def str_iftruthy(s: str | None) -> str | None: ...
def as_socket_list(sockets: Sequence[object]) -> list[socket]: ...
@@ -27,7 +27,7 @@ class Adjustments:
threads: int = ...
trusted_proxy: str | None = ...
trusted_proxy_count: int | None = ...
trusted_proxy_headers: Set[str] = ...
trusted_proxy_headers: set[str] = ...
log_untrusted_proxy_headers: bool = ...
clear_untrusted_proxy_headers: _bool_marker | bool = ...
url_scheme: str = ...

View File

@@ -1,5 +1,5 @@
from logging import Logger
from typing import Any, Callable, Mapping, NamedTuple, Sequence, Set
from typing import Any, Callable, Mapping, NamedTuple, Sequence
from .utilities import BadRequest as BadRequest
@@ -21,14 +21,14 @@ def proxy_headers_middleware(
app: Any,
trusted_proxy: str | None = ...,
trusted_proxy_count: int = ...,
trusted_proxy_headers: Set[str] | None = ...,
trusted_proxy_headers: set[str] | None = ...,
clear_untrusted: bool = ...,
log_untrusted: bool = ...,
logger: Logger = ...,
) -> Callable[..., Any]: ...
def parse_proxy_headers(
environ: Mapping[str, str], trusted_proxy_count: int, trusted_proxy_headers: Set[str], logger: Logger = ...
) -> Set[str]: ...
environ: Mapping[str, str], trusted_proxy_count: int, trusted_proxy_headers: set[str], logger: Logger = ...
) -> set[str]: ...
def strip_brackets(addr: str) -> str: ...
def clear_untrusted_headers(
environ: Mapping[str, str], untrusted_headers: Sequence[str], log_warning: bool = ..., logger: Logger = ...

View File

@@ -1,6 +1,7 @@
from collections import deque
from logging import Logger
from threading import Condition, Lock
from typing import Any, Deque, Mapping, Sequence
from typing import Any, Mapping, Sequence
from .channel import HTTPChannel
from .utilities import Error
@@ -14,7 +15,7 @@ class ThreadedTaskDispatcher:
logger: Logger = ...
queue_logger: Logger = ...
threads: set[Any] = ...
queue: Deque[Task] = ...
queue: deque[Task] = ...
lock: Lock = ...
queue_cv: Condition = ...
thread_exit_cv: Condition = ...