Skip to content

Commit c685c2d

Browse files
authored
Reduce use of deprecated typing aliases (#6358)
1 parent 7e836db commit c685c2d

File tree

19 files changed

+64
-61
lines changed

19 files changed

+64
-61
lines changed

stubs/Pygments/pygments/style.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ from typing_extensions import TypedDict
33

44
from pygments.token import _TokenType
55

6-
ansicolors: Set[str] # not intended to be mutable
6+
ansicolors: Set[str] # not intended to be mutable (== typing.AbstractSet, not builtins.set)
77

88
class _StyleDict(TypedDict):
99
color: str | None

stubs/Werkzeug/werkzeug/contrib/fixers.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
2-
from typing import Any, Iterable, Mapping, Set, Text
2+
from typing import Any, Iterable, Mapping, Text
33

44
from ..middleware.proxy_fix import ProxyFix as ProxyFix
55

@@ -18,7 +18,7 @@ class PathInfoFromRequestUriFix(object):
1818

1919
class HeaderRewriterFix(object):
2020
app: WSGIApplication
21-
remove_headers: Set[Text]
21+
remove_headers: set[Text]
2222
add_headers: list[Text]
2323
def __init__(
2424
self, app: WSGIApplication, remove_headers: Iterable[Text] | None = ..., add_headers: Iterable[Text] | None = ...

stubs/beautifulsoup4/bs4/element.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from _typeshed import Self
22
from collections.abc import Iterator
3-
from typing import Any, Callable, Generic, Iterable, List, Mapping, Pattern, Set, Tuple, Type, TypeVar, Union, overload
3+
from typing import Any, Callable, Generic, Iterable, List, Mapping, Pattern, Tuple, Type, TypeVar, Union, overload
44

55
from . import BeautifulSoup
66
from .builder import TreeBuilder
@@ -10,7 +10,7 @@ DEFAULT_OUTPUT_ENCODING: str
1010
PY3K: bool
1111
nonwhitespace_re: Pattern[str]
1212
whitespace_re: Pattern[str]
13-
PYTHON_SPECIFIC_ENCODINGS: Set[str]
13+
PYTHON_SPECIFIC_ENCODINGS: set[str]
1414

1515
class NamespacedAttribute(str):
1616
def __new__(cls: Type[Self], prefix: str, name: str | None = ..., namespace: str | None = ...) -> Self: ...

stubs/cachetools/cachetools/__init__.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from _typeshed import IdentityFunction
22
from collections.abc import Iterator, Sequence
3-
from typing import Any, Callable, ContextManager, Generic, MutableMapping, TypeVar, overload
3+
from contextlib import AbstractContextManager
4+
from typing import Any, Callable, Generic, MutableMapping, TypeVar, overload
45

56
_KT = TypeVar("_KT")
67
_VT = TypeVar("_VT")
@@ -57,10 +58,10 @@ class TTLCache(Cache[_KT, _VT]):
5758
def expire(self, time: float | None = ...) -> None: ...
5859

5960
def cached(
60-
cache: MutableMapping[_KT, Any] | None, key: Callable[..., _KT] = ..., lock: ContextManager[Any] | None = ...
61+
cache: MutableMapping[_KT, Any] | None, key: Callable[..., _KT] = ..., lock: AbstractContextManager[Any] | None = ...
6162
) -> IdentityFunction: ...
6263
def cachedmethod(
6364
cache: Callable[[Any], MutableMapping[_KT, Any] | None],
6465
key: Callable[..., _KT] = ...,
65-
lock: Callable[[Any], ContextManager[Any]] | None = ...,
66+
lock: Callable[[Any], AbstractContextManager[Any]] | None = ...,
6667
) -> IdentityFunction: ...

stubs/click/click/core.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Callable, ContextManager, Iterable, Mapping, NoReturn, Optional, Sequence, Set, Tuple, TypeVar, Union
1+
from typing import Any, Callable, ContextManager, Iterable, Mapping, NoReturn, Optional, Sequence, Tuple, TypeVar, Union
22

33
from click.formatting import HelpFormatter
44
from click.parser import OptionParser
@@ -125,7 +125,7 @@ class Command(BaseCommand):
125125
def get_params(self, ctx: Context) -> list[Parameter]: ...
126126
def format_usage(self, ctx: Context, formatter: HelpFormatter) -> None: ...
127127
def collect_usage_pieces(self, ctx: Context) -> list[str]: ...
128-
def get_help_option_names(self, ctx: Context) -> Set[str]: ...
128+
def get_help_option_names(self, ctx: Context) -> set[str]: ...
129129
def get_help_option(self, ctx: Context) -> Option | None: ...
130130
def make_parser(self, ctx: Context) -> OptionParser: ...
131131
def get_short_help_str(self, limit: int = ...) -> str: ...

stubs/click/click/parser.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Iterable, Set, Tuple
1+
from typing import Any, Iterable, Tuple
22

33
from click.core import Context
44

@@ -13,7 +13,7 @@ class Option:
1313
nargs: int
1414
const: Any
1515
obj: Any
16-
prefixes: Set[str]
16+
prefixes: set[str]
1717
_short_opts: list[str]
1818
_long_opts: list[str]
1919
def __init__(
@@ -49,7 +49,7 @@ class OptionParser:
4949
ignore_unknown_options: bool
5050
_short_opt: dict[str, Option]
5151
_long_opt: dict[str, Option]
52-
_opt_prefixes: Set[str]
52+
_opt_prefixes: set[str]
5353
_args: list[Argument]
5454
def __init__(self, ctx: Context | None = ...) -> None: ...
5555
def add_option(
Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
from typing import FrozenSet
2-
31
from cryptography.hazmat.primitives.ciphers import BlockCipherAlgorithm, CipherAlgorithm
42
from cryptography.hazmat.primitives.ciphers.modes import ModeWithNonce
53

64
class AES(BlockCipherAlgorithm, CipherAlgorithm):
75
def __init__(self, key: bytes) -> None: ...
86
block_size: int = ...
97
name: str = ...
10-
key_sizes: FrozenSet[int] = ...
8+
key_sizes: frozenset[int] = ...
119
@property
1210
def key_size(self) -> int: ...
1311

@@ -16,38 +14,38 @@ class ARC4(CipherAlgorithm):
1614
@property
1715
def key_size(self) -> int: ...
1816
name: str = ...
19-
key_sizes: FrozenSet[int] = ...
17+
key_sizes: frozenset[int] = ...
2018

2119
class Blowfish(BlockCipherAlgorithm, CipherAlgorithm):
2220
def __init__(self, key: bytes) -> None: ...
2321
@property
2422
def key_size(self) -> int: ...
2523
block_size: int = ...
2624
name: str = ...
27-
key_sizes: FrozenSet[int] = ...
25+
key_sizes: frozenset[int] = ...
2826

2927
class Camellia(BlockCipherAlgorithm, CipherAlgorithm):
3028
def __init__(self, key: bytes) -> None: ...
3129
@property
3230
def key_size(self) -> int: ...
3331
block_size: int = ...
3432
name: str = ...
35-
key_sizes: FrozenSet[int] = ...
33+
key_sizes: frozenset[int] = ...
3634

3735
class CAST5(BlockCipherAlgorithm, CipherAlgorithm):
3836
def __init__(self, key: bytes) -> None: ...
3937
@property
4038
def key_size(self) -> int: ...
4139
block_size: int = ...
4240
name: str = ...
43-
key_sizes: FrozenSet[int] = ...
41+
key_sizes: frozenset[int] = ...
4442

4543
class ChaCha20(CipherAlgorithm, ModeWithNonce):
4644
def __init__(self, key: bytes, nonce: bytes) -> None: ...
4745
@property
4846
def key_size(self) -> int: ...
4947
name: str = ...
50-
key_sizes: FrozenSet[int] = ...
48+
key_sizes: frozenset[int] = ...
5149
@property
5250
def nonce(self) -> bytes: ...
5351

@@ -57,20 +55,20 @@ class IDEA(CipherAlgorithm):
5755
def key_size(self) -> int: ...
5856
block_size: int = ...
5957
name: str = ...
60-
key_sizes: FrozenSet[int] = ...
58+
key_sizes: frozenset[int] = ...
6159

6260
class SEED(BlockCipherAlgorithm, CipherAlgorithm):
6361
def __init__(self, key: bytes) -> None: ...
6462
@property
6563
def key_size(self) -> int: ...
6664
block_size: int = ...
6765
name: str = ...
68-
key_sizes: FrozenSet[int] = ...
66+
key_sizes: frozenset[int] = ...
6967

7068
class TripleDES(BlockCipherAlgorithm, CipherAlgorithm):
7169
def __init__(self, key: bytes) -> None: ...
7270
@property
7371
def key_size(self) -> int: ...
7472
block_size: int = ...
7573
name: str = ...
76-
key_sizes: FrozenSet[int] = ...
74+
key_sizes: frozenset[int] = ...

stubs/dateparser/dateparser/__init__.pyi

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import datetime
22
import sys
3-
from typing import Set
43

54
from dateparser.date import DateDataParser
65

@@ -34,9 +33,9 @@ class _Settings(TypedDict, total=False):
3433

3534
def parse(
3635
date_string: str,
37-
date_formats: list[str] | tuple[str] | Set[str] | None = ...,
38-
languages: list[str] | tuple[str] | Set[str] | None = ...,
39-
locales: list[str] | tuple[str] | Set[str] | None = ...,
36+
date_formats: list[str] | tuple[str] | set[str] | None = ...,
37+
languages: list[str] | tuple[str] | set[str] | None = ...,
38+
locales: list[str] | tuple[str] | set[str] | None = ...,
4039
region: str | None = ...,
4140
settings: _Settings | None = ...,
4241
) -> datetime.datetime | None: ...

stubs/paramiko/paramiko/config.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import IO, Any, Dict, Iterable, Pattern, Set
1+
from typing import IO, Any, Dict, Iterable, Pattern
22

33
from paramiko.ssh_exception import ConfigParseError as ConfigParseError, CouldNotCanonicalize as CouldNotCanonicalize
44

@@ -17,7 +17,7 @@ class SSHConfig:
1717
def parse(self, file_obj: IO[str]) -> None: ...
1818
def lookup(self, hostname: str) -> SSHConfigDict: ...
1919
def canonicalize(self, hostname: str, options: SSHConfigDict, domains: Iterable[str]) -> str: ...
20-
def get_hostnames(self) -> Set[str]: ...
20+
def get_hostnames(self) -> set[str]: ...
2121

2222
class LazyFqdn:
2323
fqdn: str | None

stubs/psutil/psutil/__init__.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
2-
from typing import Any, Callable, ContextManager, Iterable, Iterator, Tuple, TypeVar
2+
from contextlib import AbstractContextManager
3+
from typing import Any, Callable, Iterable, Iterator, Tuple, TypeVar
34

45
from ._common import (
56
AIX as AIX,
@@ -122,7 +123,7 @@ class Process:
122123
def __hash__(self) -> int: ...
123124
@property
124125
def pid(self) -> int: ...
125-
def oneshot(self) -> ContextManager[None]: ...
126+
def oneshot(self) -> AbstractContextManager[None]: ...
126127
def as_dict(
127128
self, attrs: list[str] | Tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ...
128129
) -> dict[str, Any]: ...

stubs/psutil/psutil/_psbsd.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, ContextManager, NamedTuple
1+
from contextlib import AbstractContextManager
2+
from typing import Any, NamedTuple
23

34
from ._common import (
45
FREEBSD as FREEBSD,
@@ -109,7 +110,7 @@ def pids(): ...
109110
def pid_exists(pid): ...
110111
def is_zombie(pid): ...
111112
def wrap_exceptions(fun): ...
112-
def wrap_exceptions_procfs(inst) -> ContextManager[None]: ...
113+
def wrap_exceptions_procfs(inst) -> AbstractContextManager[None]: ...
113114

114115
class Process:
115116
pid: Any

stubs/psutil/psutil/_psosx.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, ContextManager, NamedTuple
1+
from contextlib import AbstractContextManager
2+
from typing import Any, NamedTuple
23

34
from ._common import (
45
AccessDenied as AccessDenied,
@@ -71,7 +72,7 @@ pid_exists: Any
7172

7273
def is_zombie(pid): ...
7374
def wrap_exceptions(fun): ...
74-
def catch_zombie(proc) -> ContextManager[None]: ...
75+
def catch_zombie(proc) -> AbstractContextManager[None]: ...
7576

7677
class Process:
7778
pid: Any

stubs/pyOpenSSL/OpenSSL/crypto.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from datetime import datetime
2-
from typing import Any, Callable, Iterable, Sequence, Set, Text, Tuple, Union
2+
from typing import Any, Callable, Iterable, Sequence, Text, Tuple, Union
33

44
from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKey, DSAPublicKey
55
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey
@@ -183,7 +183,7 @@ class NetscapeSPKI:
183183
def sign(self, pkey: PKey, digest: bytes) -> None: ...
184184
def verify(self, key: PKey) -> bool: ...
185185

186-
def get_elliptic_curves() -> Set[_EllipticCurve]: ...
186+
def get_elliptic_curves() -> set[_EllipticCurve]: ...
187187
def get_elliptic_curve(name: Text) -> _EllipticCurve: ...
188188
def dump_certificate(type: int, cert: X509) -> bytes: ...
189189
def load_certificate(type: int, buffer: bytes) -> X509: ...

stubs/pytz/pytz/__init__.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import datetime
2-
from typing import Mapping, Set
2+
from typing import Mapping
33

44
class BaseTzInfo(datetime.tzinfo):
55
zone: str = ...
@@ -33,9 +33,9 @@ def timezone(zone: str) -> _UTCclass | _StaticTzInfo | _DstTzInfo: ...
3333
def FixedOffset(offset: int) -> _UTCclass | datetime.tzinfo: ...
3434

3535
all_timezones: list[str]
36-
all_timezones_set: Set[str]
36+
all_timezones_set: set[str]
3737
common_timezones: list[str]
38-
common_timezones_set: Set[str]
38+
common_timezones_set: set[str]
3939
country_timezones: Mapping[str, list[str]]
4040
country_names: Mapping[str, str]
4141
ZERO: datetime.timedelta

stubs/redis/redis/client.pyi

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import builtins
12
from datetime import datetime, timedelta
2-
from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, Sequence, Set, Text, Type, TypeVar, Union, overload
3+
from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, Sequence, Text, Type, TypeVar, Union, overload
34
from typing_extensions import Literal
45

56
from .connection import ConnectionPool
@@ -569,12 +570,12 @@ class Redis(Generic[_StrType]):
569570
def zscan_iter(self, name, match=..., count=..., score_cast_func=...): ...
570571
def sadd(self, name: _Key, *values: _Value) -> int: ...
571572
def scard(self, name: _Key) -> int: ...
572-
def sdiff(self, keys: _Key | Iterable[_Key], *args: _Key) -> Set[_Value]: ...
573+
def sdiff(self, keys: _Key | Iterable[_Key], *args: _Key) -> builtins.set[_Value]: ...
573574
def sdiffstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> int: ...
574-
def sinter(self, keys: _Key | Iterable[_Key], *args: _Key) -> Set[_Value]: ...
575+
def sinter(self, keys: _Key | Iterable[_Key], *args: _Key) -> builtins.set[_Value]: ...
575576
def sinterstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> int: ...
576577
def sismember(self, name: _Key, value: _Value) -> bool: ...
577-
def smembers(self, name: _Key) -> Set[_StrType]: ...
578+
def smembers(self, name: _Key) -> builtins.set[_StrType]: ...
578579
def smove(self, src: _Key, dst: _Key, value: _Value) -> bool: ...
579580
@overload
580581
def spop(self, name: _Key, count: None = ...) -> _Value | None: ...
@@ -585,7 +586,7 @@ class Redis(Generic[_StrType]):
585586
@overload
586587
def srandmember(self, name: _Key, number: int) -> list[_Value]: ...
587588
def srem(self, name: _Key, *values: _Value) -> int: ...
588-
def sunion(self, keys: _Key | Iterable[_Key], *args: _Key) -> Set[_Value]: ...
589+
def sunion(self, keys: _Key | Iterable[_Key], *args: _Key) -> builtins.set[_Value]: ...
589590
def sunionstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> int: ...
590591
def xack(self, name, groupname, *ids): ...
591592
def xadd(self, name, fields, id=..., maxlen=..., approximate=...): ...

stubs/setuptools/pkg_resources/__init__.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import importlib.abc
22
import types
33
import zipimport
44
from abc import ABCMeta
5-
from typing import IO, Any, Callable, Generator, Iterable, Optional, Sequence, Set, Tuple, TypeVar, Union, overload
5+
from typing import IO, Any, Callable, Generator, Iterable, Optional, Sequence, Tuple, TypeVar, Union, overload
66

77
LegacyVersion = Any # from packaging.version
88
Version = Any # from packaging.version
@@ -203,7 +203,7 @@ class DistributionNotFound(ResolutionError):
203203
@property
204204
def req(self) -> Requirement: ...
205205
@property
206-
def requirers(self) -> Set[str]: ...
206+
def requirers(self) -> set[str]: ...
207207
@property
208208
def requirers_str(self) -> str: ...
209209
def report(self) -> str: ...
@@ -214,11 +214,11 @@ class VersionConflict(ResolutionError):
214214
@property
215215
def req(self) -> Any: ...
216216
def report(self) -> str: ...
217-
def with_context(self, required_by: Set[Distribution | str]) -> VersionConflict: ...
217+
def with_context(self, required_by: set[Distribution | str]) -> VersionConflict: ...
218218

219219
class ContextualVersionConflict(VersionConflict):
220220
@property
221-
def required_by(self) -> Set[Distribution | str]: ...
221+
def required_by(self) -> set[Distribution | str]: ...
222222

223223
class UnknownExtra(ResolutionError): ...
224224

0 commit comments

Comments
 (0)