apply black and isort (#4287)

* apply black and isort

* move some type ignores
This commit is contained in:
Jelle Zijlstra
2020-06-28 13:31:00 -07:00
committed by GitHub
parent fe58699ca5
commit 5d553c9584
800 changed files with 13875 additions and 10332 deletions

View File

@@ -2,48 +2,54 @@
import sys
import typing
from typing import (
TypeVar, Generic, Dict, overload, List, Tuple,
Any, Type, Optional, Union
)
# These are exported.
from . import abc
from typing import (
AbstractSet as Set,
Any,
AsyncIterable as AsyncIterable,
AsyncIterator as AsyncIterator,
Awaitable as Awaitable,
ByteString as ByteString,
Callable as Callable,
Container as Container,
Coroutine as Coroutine,
Dict,
Generator as Generator,
Generic,
Hashable as Hashable,
ItemsView as ItemsView,
Iterable as Iterable,
Iterator as Iterator,
Sized as Sized,
Generator as Generator,
ByteString as ByteString,
Reversible as Reversible,
KeysView as KeysView,
List,
Mapping as Mapping,
MappingView as MappingView,
ItemsView as ItemsView,
KeysView as KeysView,
ValuesView as ValuesView,
MutableMapping as MutableMapping,
Sequence as Sequence,
MutableSequence as MutableSequence,
MutableSet as MutableSet,
AbstractSet as Set,
Optional,
Reversible as Reversible,
Sequence as Sequence,
Sized as Sized,
Tuple,
Type,
TypeVar,
Union,
ValuesView as ValuesView,
overload,
)
# These are exported.
from . import abc
if sys.version_info >= (3, 6):
from typing import (
Collection as Collection,
AsyncGenerator as AsyncGenerator,
)
_S = TypeVar('_S')
_T = TypeVar('_T')
_KT = TypeVar('_KT')
_VT = TypeVar('_VT')
_S = TypeVar("_S")
_T = TypeVar("_T")
_KT = TypeVar("_KT")
_VT = TypeVar("_VT")
# namedtuple is special-cased in the type checker; the initializer is ignored.
if sys.version_info >= (3, 7):
@@ -55,6 +61,7 @@ if sys.version_info >= (3, 7):
module: Optional[str] = ...,
defaults: Optional[Iterable[Any]] = ...,
) -> Type[Tuple[Any, ...]]: ...
elif sys.version_info >= (3, 6):
def namedtuple(
typename: str,
@@ -64,6 +71,7 @@ elif sys.version_info >= (3, 6):
rename: bool = ...,
module: Optional[str] = ...,
) -> Type[Tuple[Any, ...]]: ...
else:
def namedtuple(
typename: str, field_names: Union[str, Iterable[str]], verbose: bool = ..., rename: bool = ...,
@@ -116,7 +124,7 @@ class UserList(MutableSequence[_T]):
def sort(self, *args: Any, **kwds: Any) -> None: ...
def extend(self, other: Iterable[_T]) -> None: ...
_UserStringT = TypeVar('_UserStringT', bound=UserString)
_UserStringT = TypeVar("_UserStringT", bound=UserString)
class UserString(Sequence[str]):
data: str
@@ -172,7 +180,9 @@ class UserString(Sequence[str]):
if sys.version_info >= (3, 9):
def removeprefix(self: _UserStringT, __prefix: Union[str, UserString]) -> _UserStringT: ...
def removesuffix(self: _UserStringT, __suffix: Union[str, UserString]) -> _UserStringT: ...
def replace(self: _UserStringT, old: Union[str, UserString], new: Union[str, UserString], maxsplit: int = ...) -> _UserStringT: ...
def replace(
self: _UserStringT, old: Union[str, UserString], new: Union[str, UserString], maxsplit: int = ...
) -> _UserStringT: ...
def rfind(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ...
def rindex(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ...
def rjust(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ...
@@ -189,15 +199,13 @@ class UserString(Sequence[str]):
def upper(self: _UserStringT) -> _UserStringT: ...
def zfill(self: _UserStringT, width: int) -> _UserStringT: ...
# Technically, deque only derives from MutableSequence in 3.5 (before then, the insert and index
# methods did not exist).
# But in practice it's not worth losing sleep over.
class deque(MutableSequence[_T], Generic[_T]):
@property
def maxlen(self) -> Optional[int]: ...
def __init__(self, iterable: Iterable[_T] = ...,
maxlen: Optional[int] = ...) -> None: ...
def __init__(self, iterable: Iterable[_T] = ..., maxlen: Optional[int] = ...) -> None: ...
def append(self, x: _T) -> None: ...
def appendleft(self, x: _T) -> None: ...
def clear(self) -> None: ...
@@ -212,12 +220,10 @@ class deque(MutableSequence[_T], Generic[_T]):
def remove(self, value: _T) -> None: ...
def reverse(self) -> None: ...
def rotate(self, n: int) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
def __str__(self) -> str: ...
def __hash__(self) -> int: ...
# These methods of deque don't really take slices, but we need to
# define them as taking a slice to satisfy MutableSequence.
@overload
@@ -232,12 +238,9 @@ class deque(MutableSequence[_T], Generic[_T]):
def __delitem__(self, i: int) -> None: ...
@overload
def __delitem__(self, s: slice) -> None: ...
def __contains__(self, o: object) -> bool: ...
def __reversed__(self) -> Iterator[_T]: ...
def __iadd__(self: _S, iterable: Iterable[_T]) -> _S: ...
def __add__(self, other: deque[_T]) -> deque[_T]: ...
def __mul__(self, other: int) -> deque[_T]: ...
def __imul__(self, other: int) -> None: ...
@@ -251,16 +254,13 @@ class Counter(Dict[_T, int], Generic[_T]):
def __init__(self, __iterable: Iterable[_T]) -> None: ...
def copy(self: _S) -> _S: ...
def elements(self) -> Iterator[_T]: ...
def most_common(self, n: Optional[int] = ...) -> List[Tuple[_T, int]]: ...
@overload
def subtract(self, __iterable: None = ...) -> None: ...
@overload
def subtract(self, __mapping: Mapping[_T, int]) -> None: ...
@overload
def subtract(self, __iterable: Iterable[_T]) -> None: ...
# The Iterable[Tuple[...]] argument type is not actually desirable
# (the tuples will be added as keys, breaking type safety) but
# it's included so that the signature is compatible with
@@ -272,7 +272,6 @@ class Counter(Dict[_T, int], Generic[_T]):
def update(self, __m: Union[Iterable[_T], Iterable[Tuple[_T, int]]], **kwargs: int) -> None: ...
@overload
def update(self, __m: None = ..., **kwargs: int) -> None: ...
def __add__(self, other: Counter[_T]) -> Counter[_T]: ...
def __sub__(self, other: Counter[_T]) -> Counter[_T]: ...
def __and__(self, other: Counter[_T]) -> Counter[_T]: ...
@@ -286,8 +285,10 @@ class Counter(Dict[_T, int], Generic[_T]):
class _OrderedDictKeysView(KeysView[_KT], Reversible[_KT]):
def __reversed__(self) -> Iterator[_KT]: ...
class _OrderedDictItemsView(ItemsView[_KT, _VT], Reversible[Tuple[_KT, _VT]]):
def __reversed__(self) -> Iterator[Tuple[_KT, _VT]]: ...
class _OrderedDictValuesView(ValuesView[_VT], Reversible[_VT]):
def __reversed__(self) -> Iterator[_VT]: ...
@@ -302,7 +303,6 @@ class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
default_factory: Optional[Callable[[], _VT]]
@overload
def __init__(self, **kwargs: _VT) -> None: ...
@overload
@@ -310,32 +310,26 @@ class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
@overload
def __init__(self, default_factory: Optional[Callable[[], _VT]], **kwargs: _VT) -> None: ...
@overload
def __init__(self, default_factory: Optional[Callable[[], _VT]],
map: Mapping[_KT, _VT]) -> None: ...
def __init__(self, default_factory: Optional[Callable[[], _VT]], map: Mapping[_KT, _VT]) -> None: ...
@overload
def __init__(self, default_factory: Optional[Callable[[], _VT]],
map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...
def __init__(self, default_factory: Optional[Callable[[], _VT]], map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...
@overload
def __init__(self, default_factory: Optional[Callable[[], _VT]],
iterable: Iterable[Tuple[_KT, _VT]]) -> None: ...
def __init__(self, default_factory: Optional[Callable[[], _VT]], iterable: Iterable[Tuple[_KT, _VT]]) -> None: ...
@overload
def __init__(self, default_factory: Optional[Callable[[], _VT]],
iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
def __init__(
self, default_factory: Optional[Callable[[], _VT]], iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT
) -> None: ...
def __missing__(self, key: _KT) -> _VT: ...
# TODO __reversed__
def copy(self: _S) -> _S: ...
class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
def __init__(self, *maps: Mapping[_KT, _VT]) -> None: ...
@property
def maps(self) -> List[Mapping[_KT, _VT]]: ...
def new_child(self, m: Mapping[_KT, _VT] = ...) -> typing.ChainMap[_KT, _VT]: ...
@property
def parents(self) -> typing.ChainMap[_KT, _VT]: ...
def __setitem__(self, k: _KT, v: _VT) -> None: ...
def __delitem__(self, v: _KT) -> None: ...
def __getitem__(self, k: _KT) -> _VT: ...

View File

@@ -8,23 +8,23 @@ from . import (
AsyncIterator as AsyncIterator,
Awaitable as Awaitable,
ByteString as ByteString,
Callable as Callable,
Container as Container,
Coroutine as Coroutine,
Generator as Generator,
Hashable as Hashable,
ItemsView as ItemsView,
Iterable as Iterable,
Iterator as Iterator,
Sized as Sized,
Callable as Callable,
Mapping as Mapping,
MutableMapping as MutableMapping,
Sequence as Sequence,
MutableSequence as MutableSequence,
Set as Set,
MutableSet as MutableSet,
MappingView as MappingView,
ItemsView as ItemsView,
KeysView as KeysView,
Mapping as Mapping,
MappingView as MappingView,
MutableMapping as MutableMapping,
MutableSequence as MutableSequence,
MutableSet as MutableSet,
Sequence as Sequence,
Set as Set,
Sized as Sized,
ValuesView as ValuesView,
)