Use lowercase set, frozenset and deque where possible (#6346)

This commit is contained in:
Alex Waygood
2021-11-19 23:05:45 +00:00
committed by GitHub
parent 916ca06885
commit 5c8e68f0eb
15 changed files with 77 additions and 79 deletions

View File

@@ -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
@@ -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

View File

@@ -33,7 +33,6 @@ from typing import (
BinaryIO,
ByteString,
Callable,
FrozenSet,
Generic,
Iterable,
Iterator,
@@ -45,7 +44,6 @@ from typing import (
Protocol,
Reversible,
Sequence,
Set,
Sized,
SupportsAbs,
SupportsBytes,
@@ -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: ...
@@ -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: ...

View File

@@ -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):
@@ -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] = ...,

View File

@@ -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,
@@ -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: ...

View File

@@ -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
@@ -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: ...
@@ -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: ...

View File

@@ -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]
@@ -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: ...

View File

@@ -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
@@ -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(

View File

@@ -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): ...
@@ -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: ...

View File

@@ -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]]
@@ -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

View File

@@ -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]

View File

@@ -8,7 +8,6 @@ from typing import (
Any,
AsyncGenerator,
Callable,
FrozenSet,
NoReturn,
Optional,
Protocol,
@@ -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

View File

@@ -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)
@@ -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

View File

@@ -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
@@ -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
@@ -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

View File

@@ -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]]
@@ -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(
@@ -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(

View File

@@ -378,33 +378,33 @@ class MappingView(Sized):
class ItemsView(MappingView, AbstractSet[Tuple[_KT_co, _VT_co]], Generic[_KT_co, _VT_co]):
def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... # undocumented
def __and__(self, o: Iterable[Any]) -> Set[tuple[_KT_co, _VT_co]]: ...
def __rand__(self, o: Iterable[_T]) -> Set[_T]: ...
def __and__(self, o: Iterable[Any]) -> set[tuple[_KT_co, _VT_co]]: ...
def __rand__(self, o: Iterable[_T]) -> set[_T]: ...
def __contains__(self, o: object) -> bool: ...
def __iter__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
if sys.version_info >= (3, 8):
def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
def __or__(self, o: Iterable[_T]) -> Set[tuple[_KT_co, _VT_co] | _T]: ...
def __ror__(self, o: Iterable[_T]) -> Set[tuple[_KT_co, _VT_co] | _T]: ...
def __sub__(self, o: Iterable[Any]) -> Set[tuple[_KT_co, _VT_co]]: ...
def __rsub__(self, o: Iterable[_T]) -> Set[_T]: ...
def __xor__(self, o: Iterable[_T]) -> Set[tuple[_KT_co, _VT_co] | _T]: ...
def __rxor__(self, o: Iterable[_T]) -> Set[tuple[_KT_co, _VT_co] | _T]: ...
def __or__(self, o: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
def __ror__(self, o: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
def __sub__(self, o: Iterable[Any]) -> set[tuple[_KT_co, _VT_co]]: ...
def __rsub__(self, o: Iterable[_T]) -> set[_T]: ...
def __xor__(self, o: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
def __rxor__(self, o: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]):
def __init__(self, mapping: Mapping[_KT_co, Any]) -> None: ... # undocumented
def __and__(self, o: Iterable[Any]) -> Set[_KT_co]: ...
def __rand__(self, o: Iterable[_T]) -> Set[_T]: ...
def __and__(self, o: Iterable[Any]) -> set[_KT_co]: ...
def __rand__(self, o: Iterable[_T]) -> set[_T]: ...
def __contains__(self, o: object) -> bool: ...
def __iter__(self) -> Iterator[_KT_co]: ...
if sys.version_info >= (3, 8):
def __reversed__(self) -> Iterator[_KT_co]: ...
def __or__(self, o: Iterable[_T]) -> Set[_KT_co | _T]: ...
def __ror__(self, o: Iterable[_T]) -> Set[_KT_co | _T]: ...
def __sub__(self, o: Iterable[Any]) -> Set[_KT_co]: ...
def __rsub__(self, o: Iterable[_T]) -> Set[_T]: ...
def __xor__(self, o: Iterable[_T]) -> Set[_KT_co | _T]: ...
def __rxor__(self, o: Iterable[_T]) -> Set[_KT_co | _T]: ...
def __or__(self, o: Iterable[_T]) -> set[_KT_co | _T]: ...
def __ror__(self, o: Iterable[_T]) -> set[_KT_co | _T]: ...
def __sub__(self, o: Iterable[Any]) -> set[_KT_co]: ...
def __rsub__(self, o: Iterable[_T]) -> set[_T]: ...
def __xor__(self, o: Iterable[_T]) -> set[_KT_co | _T]: ...
def __rxor__(self, o: Iterable[_T]) -> set[_KT_co | _T]: ...
class ValuesView(MappingView, Iterable[_VT_co], Generic[_VT_co]):
def __init__(self, mapping: Mapping[Any, _VT_co]) -> None: ... # undocumented