Skip to content

Commit 5c8e68f

Browse files
authored
Use lowercase set, frozenset and deque where possible (#6346)
1 parent 916ca06 commit 5c8e68f

15 files changed

+77
-79
lines changed

stdlib/bdb.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from types import CodeType, FrameType, TracebackType
2-
from typing import IO, Any, Callable, Iterable, Mapping, Set, SupportsInt, Tuple, Type, TypeVar
2+
from typing import IO, Any, Callable, Iterable, Mapping, SupportsInt, Tuple, Type, TypeVar
33

44
_T = TypeVar("_T")
55
_TraceDispatch = Callable[[FrameType, str, Any], Any] # TODO: Recursive type
@@ -11,7 +11,7 @@ class BdbQuit(Exception): ...
1111

1212
class Bdb:
1313

14-
skip: Set[str] | None
14+
skip: set[str] | None
1515
breaks: dict[str, list[int]]
1616
fncache: dict[str, str]
1717
frame_returning: FrameType | None

stdlib/builtins.pyi

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ from typing import (
3333
BinaryIO,
3434
ByteString,
3535
Callable,
36-
FrozenSet,
3736
Generic,
3837
Iterable,
3938
Iterator,
@@ -45,7 +44,6 @@ from typing import (
4544
Protocol,
4645
Reversible,
4746
Sequence,
48-
Set,
4947
Sized,
5048
SupportsAbs,
5149
SupportsBytes,
@@ -861,33 +859,33 @@ class set(MutableSet[_T], Generic[_T]):
861859
def __init__(self, __iterable: Iterable[_T] = ...) -> None: ...
862860
def add(self, __element: _T) -> None: ...
863861
def clear(self) -> None: ...
864-
def copy(self) -> Set[_T]: ...
865-
def difference(self, *s: Iterable[Any]) -> Set[_T]: ...
862+
def copy(self) -> set[_T]: ...
863+
def difference(self, *s: Iterable[Any]) -> set[_T]: ...
866864
def difference_update(self, *s: Iterable[Any]) -> None: ...
867865
def discard(self, __element: _T) -> None: ...
868-
def intersection(self, *s: Iterable[Any]) -> Set[_T]: ...
866+
def intersection(self, *s: Iterable[Any]) -> set[_T]: ...
869867
def intersection_update(self, *s: Iterable[Any]) -> None: ...
870868
def isdisjoint(self, __s: Iterable[Any]) -> bool: ...
871869
def issubset(self, __s: Iterable[Any]) -> bool: ...
872870
def issuperset(self, __s: Iterable[Any]) -> bool: ...
873871
def pop(self) -> _T: ...
874872
def remove(self, __element: _T) -> None: ...
875-
def symmetric_difference(self, __s: Iterable[_T]) -> Set[_T]: ...
873+
def symmetric_difference(self, __s: Iterable[_T]) -> set[_T]: ...
876874
def symmetric_difference_update(self, __s: Iterable[_T]) -> None: ...
877-
def union(self, *s: Iterable[_S]) -> Set[_T | _S]: ...
875+
def union(self, *s: Iterable[_S]) -> set[_T | _S]: ...
878876
def update(self, *s: Iterable[_T]) -> None: ...
879877
def __len__(self) -> int: ...
880878
def __contains__(self, __o: object) -> bool: ...
881879
def __iter__(self) -> Iterator[_T]: ...
882880
def __str__(self) -> str: ...
883-
def __and__(self, __s: AbstractSet[object]) -> Set[_T]: ...
884-
def __iand__(self, __s: AbstractSet[object]) -> Set[_T]: ...
885-
def __or__(self, __s: AbstractSet[_S]) -> Set[_T | _S]: ...
886-
def __ior__(self, __s: AbstractSet[_S]) -> Set[_T | _S]: ...
887-
def __sub__(self, __s: AbstractSet[_T | None]) -> Set[_T]: ...
888-
def __isub__(self, __s: AbstractSet[_T | None]) -> Set[_T]: ...
889-
def __xor__(self, __s: AbstractSet[_S]) -> Set[_T | _S]: ...
890-
def __ixor__(self, __s: AbstractSet[_S]) -> Set[_T | _S]: ...
881+
def __and__(self, __s: AbstractSet[object]) -> set[_T]: ...
882+
def __iand__(self, __s: AbstractSet[object]) -> set[_T]: ...
883+
def __or__(self, __s: AbstractSet[_S]) -> set[_T | _S]: ...
884+
def __ior__(self, __s: AbstractSet[_S]) -> set[_T | _S]: ...
885+
def __sub__(self, __s: AbstractSet[_T | None]) -> set[_T]: ...
886+
def __isub__(self, __s: AbstractSet[_T | None]) -> set[_T]: ...
887+
def __xor__(self, __s: AbstractSet[_S]) -> set[_T | _S]: ...
888+
def __ixor__(self, __s: AbstractSet[_S]) -> set[_T | _S]: ...
891889
def __le__(self, __s: AbstractSet[object]) -> bool: ...
892890
def __lt__(self, __s: AbstractSet[object]) -> bool: ...
893891
def __ge__(self, __s: AbstractSet[object]) -> bool: ...
@@ -898,22 +896,22 @@ class set(MutableSet[_T], Generic[_T]):
898896

899897
class frozenset(AbstractSet[_T_co], Generic[_T_co]):
900898
def __init__(self, __iterable: Iterable[_T_co] = ...) -> None: ...
901-
def copy(self) -> FrozenSet[_T_co]: ...
902-
def difference(self, *s: Iterable[object]) -> FrozenSet[_T_co]: ...
903-
def intersection(self, *s: Iterable[object]) -> FrozenSet[_T_co]: ...
899+
def copy(self) -> frozenset[_T_co]: ...
900+
def difference(self, *s: Iterable[object]) -> frozenset[_T_co]: ...
901+
def intersection(self, *s: Iterable[object]) -> frozenset[_T_co]: ...
904902
def isdisjoint(self, __s: Iterable[_T_co]) -> bool: ...
905903
def issubset(self, __s: Iterable[object]) -> bool: ...
906904
def issuperset(self, __s: Iterable[object]) -> bool: ...
907-
def symmetric_difference(self, __s: Iterable[_T_co]) -> FrozenSet[_T_co]: ...
908-
def union(self, *s: Iterable[_S]) -> FrozenSet[_T_co | _S]: ...
905+
def symmetric_difference(self, __s: Iterable[_T_co]) -> frozenset[_T_co]: ...
906+
def union(self, *s: Iterable[_S]) -> frozenset[_T_co | _S]: ...
909907
def __len__(self) -> int: ...
910908
def __contains__(self, __o: object) -> bool: ...
911909
def __iter__(self) -> Iterator[_T_co]: ...
912910
def __str__(self) -> str: ...
913-
def __and__(self, __s: AbstractSet[_T_co]) -> FrozenSet[_T_co]: ...
914-
def __or__(self, __s: AbstractSet[_S]) -> FrozenSet[_T_co | _S]: ...
915-
def __sub__(self, __s: AbstractSet[_T_co]) -> FrozenSet[_T_co]: ...
916-
def __xor__(self, __s: AbstractSet[_S]) -> FrozenSet[_T_co | _S]: ...
911+
def __and__(self, __s: AbstractSet[_T_co]) -> frozenset[_T_co]: ...
912+
def __or__(self, __s: AbstractSet[_S]) -> frozenset[_T_co | _S]: ...
913+
def __sub__(self, __s: AbstractSet[_T_co]) -> frozenset[_T_co]: ...
914+
def __xor__(self, __s: AbstractSet[_S]) -> frozenset[_T_co | _S]: ...
917915
def __le__(self, __s: AbstractSet[object]) -> bool: ...
918916
def __lt__(self, __s: AbstractSet[object]) -> bool: ...
919917
def __ge__(self, __s: AbstractSet[object]) -> bool: ...

stdlib/functools.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
import types
33
from _typeshed import SupportsItems, SupportsLessThan
4-
from typing import Any, Callable, Generic, Hashable, Iterable, NamedTuple, Sequence, Set, Sized, Tuple, Type, TypeVar, overload
4+
from typing import Any, Callable, Generic, Hashable, Iterable, NamedTuple, Sequence, Sized, Tuple, Type, TypeVar, overload
55
from typing_extensions import ParamSpec, final
66

77
if sys.version_info >= (3, 9):
@@ -125,7 +125,7 @@ def _make_key(
125125
kwds: SupportsItems[Any, Any],
126126
typed: bool,
127127
kwd_mark: Tuple[object, ...] = ...,
128-
fasttypes: Set[type] = ...,
128+
fasttypes: set[type] = ...,
129129
tuple: type = ...,
130130
type: Any = ...,
131131
len: Callable[[Sized], int] = ...,

stdlib/inspect.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import sys
33
import types
44
from _typeshed import Self
55
from collections import OrderedDict
6-
from collections.abc import Awaitable, Callable, Generator, Mapping, Sequence, Set
6+
from collections.abc import Awaitable, Callable, Generator, Mapping, Sequence
77
from types import (
88
AsyncGeneratorType,
99
BuiltinFunctionType,
@@ -313,7 +313,7 @@ class ClosureVars(NamedTuple):
313313
nonlocals: Mapping[str, Any]
314314
globals: Mapping[str, Any]
315315
builtins: Mapping[str, Any]
316-
unbound: Set[str]
316+
unbound: set[str]
317317

318318
def getclosurevars(func: Callable[..., Any]) -> ClosureVars: ...
319319
def unwrap(func: Callable[..., Any], *, stop: Callable[[Any], Any] | None = ...) -> Any: ...

stdlib/random.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import _random
22
import sys
3-
from collections.abc import Callable, Iterable, MutableSequence, Sequence, Set
3+
from collections.abc import Callable, Iterable, MutableSequence, Sequence
44
from fractions import Fraction
55
from typing import Any, NoReturn, Tuple, TypeVar
66

@@ -27,9 +27,9 @@ class Random(_random.Random):
2727
) -> list[_T]: ...
2828
def shuffle(self, x: MutableSequence[Any], random: Callable[[], float] | None = ...) -> None: ...
2929
if sys.version_info >= (3, 9):
30-
def sample(self, population: Sequence[_T] | Set[_T], k: int, *, counts: Iterable[_T] | None = ...) -> list[_T]: ...
30+
def sample(self, population: Sequence[_T] | set[_T], k: int, *, counts: Iterable[_T] | None = ...) -> list[_T]: ...
3131
else:
32-
def sample(self, population: Sequence[_T] | Set[_T], k: int) -> list[_T]: ...
32+
def sample(self, population: Sequence[_T] | set[_T], k: int) -> list[_T]: ...
3333
def random(self) -> float: ...
3434
def uniform(self, a: float, b: float) -> float: ...
3535
def triangular(self, low: float = ..., high: float = ..., mode: float | None = ...) -> float: ...
@@ -66,10 +66,10 @@ def choices(
6666
def shuffle(x: MutableSequence[Any], random: Callable[[], float] | None = ...) -> None: ...
6767

6868
if sys.version_info >= (3, 9):
69-
def sample(population: Sequence[_T] | Set[_T], k: int, *, counts: Iterable[_T] | None = ...) -> list[_T]: ...
69+
def sample(population: Sequence[_T] | set[_T], k: int, *, counts: Iterable[_T] | None = ...) -> list[_T]: ...
7070

7171
else:
72-
def sample(population: Sequence[_T] | Set[_T], k: int) -> list[_T]: ...
72+
def sample(population: Sequence[_T] | set[_T], k: int) -> list[_T]: ...
7373

7474
def random() -> float: ...
7575
def uniform(a: float, b: float) -> float: ...

stdlib/reprlib.pyi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from array import array
2-
from typing import Any, Callable, Deque, FrozenSet, Set, Tuple
2+
from collections import deque
3+
from typing import Any, Callable, Tuple
34

45
_ReprFunc = Callable[[Any], str]
56

@@ -23,9 +24,9 @@ class Repr:
2324
def repr_tuple(self, x: Tuple[Any, ...], level: int) -> str: ...
2425
def repr_list(self, x: list[Any], level: int) -> str: ...
2526
def repr_array(self, x: array[Any], level: int) -> str: ...
26-
def repr_set(self, x: Set[Any], level: int) -> str: ...
27-
def repr_frozenset(self, x: FrozenSet[Any], level: int) -> str: ...
28-
def repr_deque(self, x: Deque[Any], level: int) -> str: ...
27+
def repr_set(self, x: set[Any], level: int) -> str: ...
28+
def repr_frozenset(self, x: frozenset[Any], level: int) -> str: ...
29+
def repr_deque(self, x: deque[Any], level: int) -> str: ...
2930
def repr_dict(self, x: dict[Any, Any], level: int) -> str: ...
3031
def repr_str(self, x: str, level: int) -> str: ...
3132
def repr_int(self, x: int, level: int) -> str: ...

stdlib/shutil.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import sys
33
from _typeshed import StrOrBytesPath, StrPath, SupportsRead, SupportsWrite
4-
from typing import Any, AnyStr, Callable, Iterable, NamedTuple, Sequence, Set, TypeVar, Union, overload
4+
from typing import Any, AnyStr, Callable, Iterable, NamedTuple, Sequence, TypeVar, Union, overload
55

66
_PathT = TypeVar("_PathT", str, os.PathLike[str])
77
# Return value of some functions that may either return a path-like object that was passed in or
@@ -21,7 +21,7 @@ def copymode(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> None
2121
def copystat(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> None: ...
2222
def copy(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> _PathReturn: ...
2323
def copy2(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> _PathReturn: ...
24-
def ignore_patterns(*patterns: StrPath) -> Callable[[Any, list[str]], Set[str]]: ...
24+
def ignore_patterns(*patterns: StrPath) -> Callable[[Any, list[str]], set[str]]: ...
2525

2626
if sys.version_info >= (3, 8):
2727
def copytree(

stdlib/signal.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from enum import IntEnum
33
from types import FrameType
4-
from typing import Any, Callable, Iterable, Optional, Set, Tuple, Union
4+
from typing import Any, Callable, Iterable, Optional, Tuple, Union
55

66
if sys.platform != "win32":
77
class ItimerError(IOError): ...
@@ -167,13 +167,13 @@ def getsignal(__signalnum: _SIGNUM) -> _HANDLER: ...
167167

168168
if sys.version_info >= (3, 8):
169169
def strsignal(__signalnum: _SIGNUM) -> str | None: ...
170-
def valid_signals() -> Set[Signals]: ...
170+
def valid_signals() -> set[Signals]: ...
171171
def raise_signal(__signalnum: _SIGNUM) -> None: ...
172172

173173
if sys.platform != "win32":
174174
def pause() -> None: ...
175175
def pthread_kill(__thread_id: int, __signalnum: int) -> None: ...
176-
def pthread_sigmask(__how: int, __mask: Iterable[int]) -> Set[_SIGNUM]: ...
176+
def pthread_sigmask(__how: int, __mask: Iterable[int]) -> set[_SIGNUM]: ...
177177

178178
if sys.version_info >= (3, 7):
179179
def set_wakeup_fd(fd: int, *, warn_on_full_buffer: bool = ...) -> int: ...

stdlib/socketserver.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import sys
22
import types
33
from _typeshed import Self
44
from socket import socket as _socket
5-
from typing import Any, BinaryIO, Callable, ClassVar, Set, Tuple, Type, TypeVar, Union
5+
from typing import Any, BinaryIO, Callable, ClassVar, Tuple, Type, TypeVar, Union
66

77
_T = TypeVar("_T")
88
_RequestType = Union[_socket, Tuple[bytes, _socket]]
@@ -88,7 +88,7 @@ if sys.platform != "win32":
8888
if sys.platform != "win32":
8989
class ForkingMixIn:
9090
timeout: float | None # undocumented
91-
active_children: Set[int] | None # undocumented
91+
active_children: set[int] | None # undocumented
9292
max_children: int # undocumented
9393
if sys.version_info >= (3, 7):
9494
block_on_close: bool

stdlib/sre_parse.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import sys
22
from sre_constants import _NamedIntConstant as _NIC, error as _Error
3-
from typing import Any, FrozenSet, Iterable, List, Match, Optional, Pattern as _Pattern, Tuple, Union, overload
3+
from typing import Any, Iterable, List, Match, Optional, Pattern as _Pattern, Tuple, Union, overload
44

55
SPECIAL_CHARS: str
66
REPEAT_CHARS: str
7-
DIGITS: FrozenSet[str]
8-
OCTDIGITS: FrozenSet[str]
9-
HEXDIGITS: FrozenSet[str]
10-
ASCIILETTERS: FrozenSet[str]
11-
WHITESPACE: FrozenSet[str]
7+
DIGITS: frozenset[str]
8+
OCTDIGITS: frozenset[str]
9+
HEXDIGITS: frozenset[str]
10+
ASCIILETTERS: frozenset[str]
11+
WHITESPACE: frozenset[str]
1212
ESCAPES: dict[str, tuple[_NIC, int]]
1313
CATEGORIES: dict[str, tuple[_NIC, _NIC] | tuple[_NIC, list[tuple[_NIC, _NIC]]]]
1414
FLAGS: dict[str, int]

stdlib/sys.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ from typing import (
88
Any,
99
AsyncGenerator,
1010
Callable,
11-
FrozenSet,
1211
NoReturn,
1312
Optional,
1413
Protocol,
@@ -76,7 +75,7 @@ stdin: TextIO
7675
stdout: TextIO
7776
stderr: TextIO
7877
if sys.version_info >= (3, 10):
79-
stdlib_module_names: FrozenSet[str]
78+
stdlib_module_names: frozenset[str]
8079
__stdin__: TextIOWrapper
8180
__stdout__: TextIOWrapper
8281
__stderr__: TextIOWrapper

stdlib/tarfile.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from _typeshed import Self, StrOrBytesPath, StrPath
55
from collections.abc import Callable, Iterable, Iterator, Mapping
66
from gzip import _ReadableFileobj as _GzipReadableFileobj, _WritableFileobj as _GzipWritableFileobj
77
from types import TracebackType
8-
from typing import IO, Protocol, Set, Tuple, Type, TypeVar, overload
8+
from typing import IO, Protocol, Tuple, Type, TypeVar, overload
99
from typing_extensions import Literal
1010

1111
_TF = TypeVar("_TF", bound=TarFile)
@@ -67,7 +67,7 @@ REGULAR_TYPES: Tuple[bytes, ...]
6767
GNU_TYPES: Tuple[bytes, ...]
6868
PAX_FIELDS: Tuple[str, ...]
6969
PAX_NUMBER_FIELDS: dict[str, type]
70-
PAX_NAME_FIELDS: Set[str]
70+
PAX_NAME_FIELDS: set[str]
7171

7272
ENCODING: str
7373

stdlib/tokenize.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import sys
22
from _typeshed import StrOrBytesPath
33
from builtins import open as _builtin_open
44
from token import * # noqa: F403
5-
from typing import Any, Callable, Generator, Iterable, NamedTuple, Pattern, Sequence, Set, TextIO, Tuple, Union
5+
from typing import Any, Callable, Generator, Iterable, NamedTuple, Pattern, Sequence, TextIO, Tuple, Union
66

77
if sys.version_info < (3, 7):
88
COMMENT: int
@@ -69,7 +69,7 @@ Floatnumber: str # undocumented
6969
Imagnumber: str # undocumented
7070
Number: str # undocumented
7171

72-
def _all_string_prefixes() -> Set[str]: ... # undocumented
72+
def _all_string_prefixes() -> set[str]: ... # undocumented
7373

7474
StringPrefix: str # undocumented
7575

@@ -95,7 +95,7 @@ PseudoExtras: str # undocumented
9595
PseudoToken: str # undocumented
9696

9797
endpats: dict[str, str] # undocumented
98-
single_quoted: Set[str] # undocumented
99-
triple_quoted: Set[str] # undocumented
98+
single_quoted: set[str] # undocumented
99+
triple_quoted: set[str] # undocumented
100100

101101
tabsize: int # undocumented

stdlib/traceback.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from _typeshed import SupportsWrite
33
from types import FrameType, TracebackType
4-
from typing import IO, Any, Generator, Iterable, Iterator, List, Mapping, Optional, Set, Tuple, Type
4+
from typing import IO, Any, Generator, Iterable, Iterator, List, Mapping, Optional, Tuple, Type
55

66
_PT = Tuple[str, int, str, Optional[str]]
77

@@ -90,7 +90,7 @@ class TracebackException:
9090
lookup_lines: bool = ...,
9191
capture_locals: bool = ...,
9292
compact: bool = ...,
93-
_seen: Set[int] | None = ...,
93+
_seen: set[int] | None = ...,
9494
) -> None: ...
9595
@classmethod
9696
def from_exception(
@@ -112,7 +112,7 @@ class TracebackException:
112112
limit: int | None = ...,
113113
lookup_lines: bool = ...,
114114
capture_locals: bool = ...,
115-
_seen: Set[int] | None = ...,
115+
_seen: set[int] | None = ...,
116116
) -> None: ...
117117
@classmethod
118118
def from_exception(

0 commit comments

Comments
 (0)