Big diff: Use new "|" union syntax (#5872)

This commit is contained in:
Akuli
2021-08-08 12:05:21 +03:00
committed by GitHub
parent b9adb7a874
commit ee487304d7
578 changed files with 8080 additions and 8966 deletions

View File

@@ -1,6 +1,6 @@
import sys
from _typeshed import Self
from typing import Any, Dict, Generic, List, NoReturn, Optional, Tuple, Type, TypeVar, Union, overload
from typing import Any, Dict, Generic, List, NoReturn, Tuple, Type, TypeVar, overload
if sys.version_info >= (3, 10):
from typing import (
@@ -28,26 +28,21 @@ _VT = TypeVar("_VT")
if sys.version_info >= (3, 7):
def namedtuple(
typename: str,
field_names: Union[str, Iterable[str]],
field_names: str | Iterable[str],
*,
rename: bool = ...,
module: Optional[str] = ...,
defaults: Optional[Iterable[Any]] = ...,
module: str | None = ...,
defaults: Iterable[Any] | None = ...,
) -> Type[Tuple[Any, ...]]: ...
else:
def namedtuple(
typename: str,
field_names: Union[str, Iterable[str]],
*,
verbose: bool = ...,
rename: bool = ...,
module: Optional[str] = ...,
typename: str, field_names: str | Iterable[str], *, verbose: bool = ..., rename: bool = ..., module: str | None = ...
) -> Type[Tuple[Any, ...]]: ...
class UserDict(MutableMapping[_KT, _VT]):
data: Dict[_KT, _VT]
def __init__(self, __dict: Optional[Mapping[_KT, _VT]] = ..., **kwargs: _VT) -> None: ...
def __init__(self, __dict: Mapping[_KT, _VT] | None = ..., **kwargs: _VT) -> None: ...
def __len__(self) -> int: ...
def __getitem__(self, key: _KT) -> _VT: ...
def __setitem__(self, key: _KT, item: _VT) -> None: ...
@@ -56,11 +51,11 @@ class UserDict(MutableMapping[_KT, _VT]):
def __contains__(self, key: object) -> bool: ...
def copy(self: _S) -> _S: ...
@classmethod
def fromkeys(cls: Type[_S], iterable: Iterable[_KT], value: Optional[_VT] = ...) -> _S: ...
def fromkeys(cls: Type[_S], iterable: Iterable[_KT], value: _VT | None = ...) -> _S: ...
class UserList(MutableSequence[_T]):
data: List[_T]
def __init__(self, initlist: Optional[Iterable[_T]] = ...) -> None: ...
def __init__(self, initlist: Iterable[_T] | None = ...) -> None: ...
def __lt__(self, other: object) -> bool: ...
def __le__(self, other: object) -> bool: ...
def __gt__(self, other: object) -> bool: ...
@@ -75,7 +70,7 @@ class UserList(MutableSequence[_T]):
def __setitem__(self, i: int, o: _T) -> None: ...
@overload
def __setitem__(self, i: slice, o: Iterable[_T]) -> None: ...
def __delitem__(self, i: Union[int, slice]) -> None: ...
def __delitem__(self, i: int | slice) -> None: ...
def __add__(self: _S, other: Iterable[_T]) -> _S: ...
def __iadd__(self: _S, other: Iterable[_T]) -> _S: ...
def __mul__(self: _S, n: int) -> _S: ...
@@ -101,28 +96,28 @@ class UserString(Sequence[str]):
def __float__(self) -> float: ...
def __complex__(self) -> complex: ...
def __getnewargs__(self) -> Tuple[str]: ...
def __lt__(self, string: Union[str, UserString]) -> bool: ...
def __le__(self, string: Union[str, UserString]) -> bool: ...
def __gt__(self, string: Union[str, UserString]) -> bool: ...
def __ge__(self, string: Union[str, UserString]) -> bool: ...
def __lt__(self, string: str | UserString) -> bool: ...
def __le__(self, string: str | UserString) -> bool: ...
def __gt__(self, string: str | UserString) -> bool: ...
def __ge__(self, string: str | UserString) -> bool: ...
def __contains__(self, char: object) -> bool: ...
def __len__(self) -> int: ...
# It should return a str to implement Sequence correctly, but it doesn't.
def __getitem__(self: _UserStringT, i: Union[int, slice]) -> _UserStringT: ... # type: ignore
def __getitem__(self: _UserStringT, i: int | slice) -> _UserStringT: ... # type: ignore
def __add__(self: _UserStringT, other: object) -> _UserStringT: ...
def __mul__(self: _UserStringT, n: int) -> _UserStringT: ...
def __mod__(self: _UserStringT, args: Any) -> _UserStringT: ...
def capitalize(self: _UserStringT) -> _UserStringT: ...
def casefold(self: _UserStringT) -> _UserStringT: ...
def center(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ...
def count(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ...
def count(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ...
if sys.version_info >= (3, 8):
def encode(self: UserString, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> bytes: ...
def encode(self: UserString, encoding: str | None = ..., errors: str | None = ...) -> bytes: ...
else:
def encode(self: _UserStringT, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> _UserStringT: ...
def endswith(self, suffix: Union[str, Tuple[str, ...]], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ...
def encode(self: _UserStringT, encoding: str | None = ..., errors: str | None = ...) -> _UserStringT: ...
def endswith(self, suffix: str | Tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ...
def expandtabs(self: _UserStringT, tabsize: int = ...) -> _UserStringT: ...
def find(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ...
def find(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ...
def format(self, *args: Any, **kwds: Any) -> str: ...
def format_map(self, mapping: Mapping[str, Any]) -> str: ...
def index(self, sub: str, start: int = ..., end: int = ...) -> int: ...
@@ -140,30 +135,28 @@ class UserString(Sequence[str]):
def join(self, seq: Iterable[str]) -> str: ...
def ljust(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ...
def lower(self: _UserStringT) -> _UserStringT: ...
def lstrip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ...
def lstrip(self: _UserStringT, chars: str | None = ...) -> _UserStringT: ...
@staticmethod
@overload
def maketrans(x: Union[Dict[int, _T], Dict[str, _T], Dict[Union[str, int], _T]]) -> Dict[int, _T]: ...
def maketrans(x: Dict[int, _T] | Dict[str, _T] | Dict[str | int, _T]) -> Dict[int, _T]: ...
@staticmethod
@overload
def maketrans(x: str, y: str, z: str = ...) -> Dict[int, Union[int, None]]: ...
def maketrans(x: str, y: str, z: str = ...) -> Dict[int, int | None]: ...
def partition(self, sep: str) -> Tuple[str, str, 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 rfind(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ...
def rindex(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ...
def removeprefix(self: _UserStringT, __prefix: str | UserString) -> _UserStringT: ...
def removesuffix(self: _UserStringT, __suffix: str | UserString) -> _UserStringT: ...
def replace(self: _UserStringT, old: str | UserString, new: str | UserString, maxsplit: int = ...) -> _UserStringT: ...
def rfind(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ...
def rindex(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ...
def rjust(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ...
def rpartition(self, sep: str) -> Tuple[str, str, str]: ...
def rstrip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ...
def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ...
def rsplit(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ...
def rstrip(self: _UserStringT, chars: str | None = ...) -> _UserStringT: ...
def split(self, sep: str | None = ..., maxsplit: int = ...) -> List[str]: ...
def rsplit(self, sep: str | None = ..., maxsplit: int = ...) -> List[str]: ...
def splitlines(self, keepends: bool = ...) -> List[str]: ...
def startswith(self, prefix: Union[str, Tuple[str, ...]], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ...
def strip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ...
def startswith(self, prefix: str | Tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ...
def strip(self: _UserStringT, chars: str | None = ...) -> _UserStringT: ...
def swapcase(self: _UserStringT) -> _UserStringT: ...
def title(self: _UserStringT) -> _UserStringT: ...
def translate(self: _UserStringT, *args: Any) -> _UserStringT: ...
@@ -172,8 +165,8 @@ class UserString(Sequence[str]):
class deque(MutableSequence[_T], Generic[_T]):
@property
def maxlen(self) -> Optional[int]: ...
def __init__(self, iterable: Iterable[_T] = ..., maxlen: Optional[int] = ...) -> None: ...
def maxlen(self) -> int | None: ...
def __init__(self, iterable: Iterable[_T] = ..., maxlen: int | None = ...) -> None: ...
def append(self, x: _T) -> None: ...
def appendleft(self, x: _T) -> None: ...
def clear(self) -> None: ...
@@ -221,9 +214,9 @@ 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]]: ...
def most_common(self, n: int | None = ...) -> List[Tuple[_T, int]]: ...
@classmethod
def fromkeys(cls, iterable: Any, v: Optional[int] = ...) -> NoReturn: ... # type: ignore
def fromkeys(cls, iterable: Any, v: int | None = ...) -> NoReturn: ... # type: ignore
@overload
def subtract(self, __iterable: None = ...) -> None: ...
@overload
@@ -238,7 +231,7 @@ class Counter(Dict[_T, int], Generic[_T]):
@overload
def update(self, __m: Mapping[_T, int], **kwargs: int) -> None: ...
@overload
def update(self, __m: Union[Iterable[_T], Iterable[Tuple[_T, int]]], **kwargs: int) -> None: ...
def update(self, __m: 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]: ...
@@ -271,23 +264,21 @@ class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
def values(self) -> _OrderedDictValuesView[_VT]: ...
class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
default_factory: Optional[Callable[[], _VT]]
default_factory: Callable[[], _VT] | None
@overload
def __init__(self, **kwargs: _VT) -> None: ...
@overload
def __init__(self, default_factory: Optional[Callable[[], _VT]]) -> None: ...
def __init__(self, default_factory: Callable[[], _VT] | None) -> None: ...
@overload
def __init__(self, default_factory: Optional[Callable[[], _VT]], **kwargs: _VT) -> None: ...
def __init__(self, default_factory: Callable[[], _VT] | None, **kwargs: _VT) -> None: ...
@overload
def __init__(self, default_factory: Optional[Callable[[], _VT]], map: Mapping[_KT, _VT]) -> None: ...
def __init__(self, default_factory: Callable[[], _VT] | None, 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: Callable[[], _VT] | None, 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: Callable[[], _VT] | None, 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: Callable[[], _VT] | None, iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
def __missing__(self, key: _KT) -> _VT: ...
# TODO __reversed__
def copy(self: _S) -> _S: ...
@@ -295,7 +286,7 @@ class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
maps: List[Mapping[_KT, _VT]]
def __init__(self, *maps: Mapping[_KT, _VT]) -> None: ...
def new_child(self, m: Optional[Mapping[_KT, _VT]] = ...) -> ChainMap[_KT, _VT]: ...
def new_child(self, m: Mapping[_KT, _VT] | None = ...) -> ChainMap[_KT, _VT]: ...
@property
def parents(self) -> ChainMap[_KT, _VT]: ...
def __setitem__(self, k: _KT, v: _VT) -> None: ...