Skip to content

Use lowercase set, frozenset and deque where possible #6346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stdlib/bdb.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from types import CodeType, FrameType, TracebackType
from typing import IO, Any, Callable, Iterable, Mapping, Set, SupportsInt, Tuple, Type, TypeVar
from typing import IO, Any, Callable, Iterable, Mapping, SupportsInt, Tuple, Type, TypeVar

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

class Bdb:

skip: Set[str] | None
skip: set[str] | None
breaks: dict[str, list[int]]
fncache: dict[str, str]
frame_returning: FrameType | None
Expand Down
46 changes: 22 additions & 24 deletions stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ from typing import (
BinaryIO,
ByteString,
Callable,
FrozenSet,
Generic,
Iterable,
Iterator,
Expand All @@ -45,7 +44,6 @@ from typing import (
Protocol,
Reversible,
Sequence,
Set,
Sized,
SupportsAbs,
SupportsBytes,
Expand Down Expand Up @@ -861,33 +859,33 @@ class set(MutableSet[_T], Generic[_T]):
def __init__(self, __iterable: Iterable[_T] = ...) -> None: ...
def add(self, __element: _T) -> None: ...
def clear(self) -> None: ...
def copy(self) -> Set[_T]: ...
def difference(self, *s: Iterable[Any]) -> Set[_T]: ...
def copy(self) -> set[_T]: ...
def difference(self, *s: Iterable[Any]) -> set[_T]: ...
def difference_update(self, *s: Iterable[Any]) -> None: ...
def discard(self, __element: _T) -> None: ...
def intersection(self, *s: Iterable[Any]) -> Set[_T]: ...
def intersection(self, *s: Iterable[Any]) -> set[_T]: ...
def intersection_update(self, *s: Iterable[Any]) -> None: ...
def isdisjoint(self, __s: Iterable[Any]) -> bool: ...
def issubset(self, __s: Iterable[Any]) -> bool: ...
def issuperset(self, __s: Iterable[Any]) -> bool: ...
def pop(self) -> _T: ...
def remove(self, __element: _T) -> None: ...
def symmetric_difference(self, __s: Iterable[_T]) -> Set[_T]: ...
def symmetric_difference(self, __s: Iterable[_T]) -> set[_T]: ...
def symmetric_difference_update(self, __s: Iterable[_T]) -> None: ...
def union(self, *s: Iterable[_S]) -> Set[_T | _S]: ...
def union(self, *s: Iterable[_S]) -> set[_T | _S]: ...
def update(self, *s: Iterable[_T]) -> None: ...
def __len__(self) -> int: ...
def __contains__(self, __o: object) -> bool: ...
def __iter__(self) -> Iterator[_T]: ...
def __str__(self) -> str: ...
def __and__(self, __s: AbstractSet[object]) -> Set[_T]: ...
def __iand__(self, __s: AbstractSet[object]) -> Set[_T]: ...
def __or__(self, __s: AbstractSet[_S]) -> Set[_T | _S]: ...
def __ior__(self, __s: AbstractSet[_S]) -> Set[_T | _S]: ...
def __sub__(self, __s: AbstractSet[_T | None]) -> Set[_T]: ...
def __isub__(self, __s: AbstractSet[_T | None]) -> Set[_T]: ...
def __xor__(self, __s: AbstractSet[_S]) -> Set[_T | _S]: ...
def __ixor__(self, __s: AbstractSet[_S]) -> Set[_T | _S]: ...
def __and__(self, __s: AbstractSet[object]) -> set[_T]: ...
def __iand__(self, __s: AbstractSet[object]) -> set[_T]: ...
def __or__(self, __s: AbstractSet[_S]) -> set[_T | _S]: ...
def __ior__(self, __s: AbstractSet[_S]) -> set[_T | _S]: ...
def __sub__(self, __s: AbstractSet[_T | None]) -> set[_T]: ...
def __isub__(self, __s: AbstractSet[_T | None]) -> set[_T]: ...
def __xor__(self, __s: AbstractSet[_S]) -> set[_T | _S]: ...
def __ixor__(self, __s: AbstractSet[_S]) -> set[_T | _S]: ...
def __le__(self, __s: AbstractSet[object]) -> bool: ...
def __lt__(self, __s: AbstractSet[object]) -> bool: ...
def __ge__(self, __s: AbstractSet[object]) -> bool: ...
Expand All @@ -898,22 +896,22 @@ class set(MutableSet[_T], Generic[_T]):

class frozenset(AbstractSet[_T_co], Generic[_T_co]):
def __init__(self, __iterable: Iterable[_T_co] = ...) -> None: ...
def copy(self) -> FrozenSet[_T_co]: ...
def difference(self, *s: Iterable[object]) -> FrozenSet[_T_co]: ...
def intersection(self, *s: Iterable[object]) -> FrozenSet[_T_co]: ...
def copy(self) -> frozenset[_T_co]: ...
def difference(self, *s: Iterable[object]) -> frozenset[_T_co]: ...
def intersection(self, *s: Iterable[object]) -> frozenset[_T_co]: ...
def isdisjoint(self, __s: Iterable[_T_co]) -> bool: ...
def issubset(self, __s: Iterable[object]) -> bool: ...
def issuperset(self, __s: Iterable[object]) -> bool: ...
def symmetric_difference(self, __s: Iterable[_T_co]) -> FrozenSet[_T_co]: ...
def union(self, *s: Iterable[_S]) -> FrozenSet[_T_co | _S]: ...
def symmetric_difference(self, __s: Iterable[_T_co]) -> frozenset[_T_co]: ...
def union(self, *s: Iterable[_S]) -> frozenset[_T_co | _S]: ...
def __len__(self) -> int: ...
def __contains__(self, __o: object) -> bool: ...
def __iter__(self) -> Iterator[_T_co]: ...
def __str__(self) -> str: ...
def __and__(self, __s: AbstractSet[_T_co]) -> FrozenSet[_T_co]: ...
def __or__(self, __s: AbstractSet[_S]) -> FrozenSet[_T_co | _S]: ...
def __sub__(self, __s: AbstractSet[_T_co]) -> FrozenSet[_T_co]: ...
def __xor__(self, __s: AbstractSet[_S]) -> FrozenSet[_T_co | _S]: ...
def __and__(self, __s: AbstractSet[_T_co]) -> frozenset[_T_co]: ...
def __or__(self, __s: AbstractSet[_S]) -> frozenset[_T_co | _S]: ...
def __sub__(self, __s: AbstractSet[_T_co]) -> frozenset[_T_co]: ...
def __xor__(self, __s: AbstractSet[_S]) -> frozenset[_T_co | _S]: ...
def __le__(self, __s: AbstractSet[object]) -> bool: ...
def __lt__(self, __s: AbstractSet[object]) -> bool: ...
def __ge__(self, __s: AbstractSet[object]) -> bool: ...
Expand Down
4 changes: 2 additions & 2 deletions stdlib/functools.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
import types
from _typeshed import SupportsItems, SupportsLessThan
from typing import Any, Callable, Generic, Hashable, Iterable, NamedTuple, Sequence, Set, Sized, Tuple, Type, TypeVar, overload
from typing import Any, Callable, Generic, Hashable, Iterable, NamedTuple, Sequence, Sized, Tuple, Type, TypeVar, overload
from typing_extensions import ParamSpec, final

if sys.version_info >= (3, 9):
Expand Down Expand Up @@ -125,7 +125,7 @@ def _make_key(
kwds: SupportsItems[Any, Any],
typed: bool,
kwd_mark: Tuple[object, ...] = ...,
fasttypes: Set[type] = ...,
fasttypes: set[type] = ...,
tuple: type = ...,
type: Any = ...,
len: Callable[[Sized], int] = ...,
Expand Down
4 changes: 2 additions & 2 deletions stdlib/inspect.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import sys
import types
from _typeshed import Self
from collections import OrderedDict
from collections.abc import Awaitable, Callable, Generator, Mapping, Sequence, Set
from collections.abc import Awaitable, Callable, Generator, Mapping, Sequence
from types import (
AsyncGeneratorType,
BuiltinFunctionType,
Expand Down Expand Up @@ -313,7 +313,7 @@ class ClosureVars(NamedTuple):
nonlocals: Mapping[str, Any]
globals: Mapping[str, Any]
builtins: Mapping[str, Any]
unbound: Set[str]
unbound: set[str]

def getclosurevars(func: Callable[..., Any]) -> ClosureVars: ...
def unwrap(func: Callable[..., Any], *, stop: Callable[[Any], Any] | None = ...) -> Any: ...
Expand Down
10 changes: 5 additions & 5 deletions stdlib/random.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _random
import sys
from collections.abc import Callable, Iterable, MutableSequence, Sequence, Set
from collections.abc import Callable, Iterable, MutableSequence, Sequence
from fractions import Fraction
from typing import Any, NoReturn, Tuple, TypeVar

Expand All @@ -27,9 +27,9 @@ class Random(_random.Random):
) -> list[_T]: ...
def shuffle(self, x: MutableSequence[Any], random: Callable[[], float] | None = ...) -> None: ...
if sys.version_info >= (3, 9):
def sample(self, population: Sequence[_T] | Set[_T], k: int, *, counts: Iterable[_T] | None = ...) -> list[_T]: ...
def sample(self, population: Sequence[_T] | set[_T], k: int, *, counts: Iterable[_T] | None = ...) -> list[_T]: ...
else:
def sample(self, population: Sequence[_T] | Set[_T], k: int) -> list[_T]: ...
def sample(self, population: Sequence[_T] | set[_T], k: int) -> list[_T]: ...
def random(self) -> float: ...
def uniform(self, a: float, b: float) -> float: ...
def triangular(self, low: float = ..., high: float = ..., mode: float | None = ...) -> float: ...
Expand Down Expand Up @@ -66,10 +66,10 @@ def choices(
def shuffle(x: MutableSequence[Any], random: Callable[[], float] | None = ...) -> None: ...

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

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

def random() -> float: ...
def uniform(a: float, b: float) -> float: ...
Expand Down
9 changes: 5 additions & 4 deletions stdlib/reprlib.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from array import array
from typing import Any, Callable, Deque, FrozenSet, Set, Tuple
from collections import deque
from typing import Any, Callable, Tuple

_ReprFunc = Callable[[Any], str]

Expand All @@ -23,9 +24,9 @@ class Repr:
def repr_tuple(self, x: Tuple[Any, ...], level: int) -> str: ...
def repr_list(self, x: list[Any], level: int) -> str: ...
def repr_array(self, x: array[Any], level: int) -> str: ...
def repr_set(self, x: Set[Any], level: int) -> str: ...
def repr_frozenset(self, x: FrozenSet[Any], level: int) -> str: ...
def repr_deque(self, x: Deque[Any], level: int) -> str: ...
def repr_set(self, x: set[Any], level: int) -> str: ...
def repr_frozenset(self, x: frozenset[Any], level: int) -> str: ...
def repr_deque(self, x: deque[Any], level: int) -> str: ...
def repr_dict(self, x: dict[Any, Any], level: int) -> str: ...
def repr_str(self, x: str, level: int) -> str: ...
def repr_int(self, x: int, level: int) -> str: ...
Expand Down
4 changes: 2 additions & 2 deletions stdlib/shutil.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import sys
from _typeshed import StrOrBytesPath, StrPath, SupportsRead, SupportsWrite
from typing import Any, AnyStr, Callable, Iterable, NamedTuple, Sequence, Set, TypeVar, Union, overload
from typing import Any, AnyStr, Callable, Iterable, NamedTuple, Sequence, TypeVar, Union, overload

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

if sys.version_info >= (3, 8):
def copytree(
Expand Down
6 changes: 3 additions & 3 deletions stdlib/signal.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from enum import IntEnum
from types import FrameType
from typing import Any, Callable, Iterable, Optional, Set, Tuple, Union
from typing import Any, Callable, Iterable, Optional, Tuple, Union

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

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

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

if sys.version_info >= (3, 7):
def set_wakeup_fd(fd: int, *, warn_on_full_buffer: bool = ...) -> int: ...
Expand Down
4 changes: 2 additions & 2 deletions stdlib/socketserver.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sys
import types
from _typeshed import Self
from socket import socket as _socket
from typing import Any, BinaryIO, Callable, ClassVar, Set, Tuple, Type, TypeVar, Union
from typing import Any, BinaryIO, Callable, ClassVar, Tuple, Type, TypeVar, Union

_T = TypeVar("_T")
_RequestType = Union[_socket, Tuple[bytes, _socket]]
Expand Down Expand Up @@ -88,7 +88,7 @@ if sys.platform != "win32":
if sys.platform != "win32":
class ForkingMixIn:
timeout: float | None # undocumented
active_children: Set[int] | None # undocumented
active_children: set[int] | None # undocumented
max_children: int # undocumented
if sys.version_info >= (3, 7):
block_on_close: bool
Expand Down
12 changes: 6 additions & 6 deletions stdlib/sre_parse.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import sys
from sre_constants import _NamedIntConstant as _NIC, error as _Error
from typing import Any, FrozenSet, Iterable, List, Match, Optional, Pattern as _Pattern, Tuple, Union, overload
from typing import Any, Iterable, List, Match, Optional, Pattern as _Pattern, Tuple, Union, overload

SPECIAL_CHARS: str
REPEAT_CHARS: str
DIGITS: FrozenSet[str]
OCTDIGITS: FrozenSet[str]
HEXDIGITS: FrozenSet[str]
ASCIILETTERS: FrozenSet[str]
WHITESPACE: FrozenSet[str]
DIGITS: frozenset[str]
OCTDIGITS: frozenset[str]
HEXDIGITS: frozenset[str]
ASCIILETTERS: frozenset[str]
WHITESPACE: frozenset[str]
ESCAPES: dict[str, tuple[_NIC, int]]
CATEGORIES: dict[str, tuple[_NIC, _NIC] | tuple[_NIC, list[tuple[_NIC, _NIC]]]]
FLAGS: dict[str, int]
Expand Down
3 changes: 1 addition & 2 deletions stdlib/sys.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ from typing import (
Any,
AsyncGenerator,
Callable,
FrozenSet,
NoReturn,
Optional,
Protocol,
Expand Down Expand Up @@ -76,7 +75,7 @@ stdin: TextIO
stdout: TextIO
stderr: TextIO
if sys.version_info >= (3, 10):
stdlib_module_names: FrozenSet[str]
stdlib_module_names: frozenset[str]
__stdin__: TextIOWrapper
__stdout__: TextIOWrapper
__stderr__: TextIOWrapper
Expand Down
4 changes: 2 additions & 2 deletions stdlib/tarfile.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from _typeshed import Self, StrOrBytesPath, StrPath
from collections.abc import Callable, Iterable, Iterator, Mapping
from gzip import _ReadableFileobj as _GzipReadableFileobj, _WritableFileobj as _GzipWritableFileobj
from types import TracebackType
from typing import IO, Protocol, Set, Tuple, Type, TypeVar, overload
from typing import IO, Protocol, Tuple, Type, TypeVar, overload
from typing_extensions import Literal

_TF = TypeVar("_TF", bound=TarFile)
Expand Down Expand Up @@ -67,7 +67,7 @@ REGULAR_TYPES: Tuple[bytes, ...]
GNU_TYPES: Tuple[bytes, ...]
PAX_FIELDS: Tuple[str, ...]
PAX_NUMBER_FIELDS: dict[str, type]
PAX_NAME_FIELDS: Set[str]
PAX_NAME_FIELDS: set[str]

ENCODING: str

Expand Down
8 changes: 4 additions & 4 deletions stdlib/tokenize.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sys
from _typeshed import StrOrBytesPath
from builtins import open as _builtin_open
from token import * # noqa: F403
from typing import Any, Callable, Generator, Iterable, NamedTuple, Pattern, Sequence, Set, TextIO, Tuple, Union
from typing import Any, Callable, Generator, Iterable, NamedTuple, Pattern, Sequence, TextIO, Tuple, Union

if sys.version_info < (3, 7):
COMMENT: int
Expand Down Expand Up @@ -69,7 +69,7 @@ Floatnumber: str # undocumented
Imagnumber: str # undocumented
Number: str # undocumented

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

StringPrefix: str # undocumented

Expand All @@ -95,7 +95,7 @@ PseudoExtras: str # undocumented
PseudoToken: str # undocumented

endpats: dict[str, str] # undocumented
single_quoted: Set[str] # undocumented
triple_quoted: Set[str] # undocumented
single_quoted: set[str] # undocumented
triple_quoted: set[str] # undocumented

tabsize: int # undocumented
6 changes: 3 additions & 3 deletions stdlib/traceback.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from _typeshed import SupportsWrite
from types import FrameType, TracebackType
from typing import IO, Any, Generator, Iterable, Iterator, List, Mapping, Optional, Set, Tuple, Type
from typing import IO, Any, Generator, Iterable, Iterator, List, Mapping, Optional, Tuple, Type

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

Expand Down Expand Up @@ -90,7 +90,7 @@ class TracebackException:
lookup_lines: bool = ...,
capture_locals: bool = ...,
compact: bool = ...,
_seen: Set[int] | None = ...,
_seen: set[int] | None = ...,
) -> None: ...
@classmethod
def from_exception(
Expand All @@ -112,7 +112,7 @@ class TracebackException:
limit: int | None = ...,
lookup_lines: bool = ...,
capture_locals: bool = ...,
_seen: Set[int] | None = ...,
_seen: set[int] | None = ...,
) -> None: ...
@classmethod
def from_exception(
Expand Down
Loading