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

@@ -17,7 +17,7 @@ Any = object()
class TypeVar:
__name__: str
__bound__: Optional[Type[Any]]
__bound__: Type[Any] | None
__constraints__: Tuple[Type[Any], ...]
__covariant__: bool
__contravariant__: bool
@@ -25,7 +25,7 @@ class TypeVar:
self,
name: str,
*constraints: Type[Any],
bound: Union[None, Type[Any], str] = ...,
bound: None | Type[Any] | str = ...,
covariant: bool = ...,
contravariant: bool = ...,
) -> None: ...
@@ -67,11 +67,11 @@ if sys.version_info >= (3, 10):
def __init__(self, origin: ParamSpec) -> None: ...
class ParamSpec:
__name__: str
__bound__: Optional[Type[Any]]
__bound__: Type[Any] | None
__covariant__: bool
__contravariant__: bool
def __init__(
self, name: str, *, bound: Union[None, Type[Any], str] = ..., contravariant: bool = ..., covariant: bool = ...
self, name: str, *, bound: None | Type[Any] | str = ..., contravariant: bool = ..., covariant: bool = ...
) -> None: ...
@property
def args(self) -> ParamSpecArgs: ...
@@ -204,11 +204,11 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
@overload
@abstractmethod
def throw(
self, __typ: Type[BaseException], __val: Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ...
self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...
) -> _T_co: ...
@overload
@abstractmethod
def throw(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> _T_co: ...
def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ...
def close(self) -> None: ...
def __iter__(self) -> Generator[_T_co, _T_contra, _V_co]: ...
@property
@@ -218,7 +218,7 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
@property
def gi_running(self) -> bool: ...
@property
def gi_yieldfrom(self) -> Optional[Generator[Any, Any, Any]]: ...
def gi_yieldfrom(self) -> Generator[Any, Any, Any] | None: ...
@runtime_checkable
class Awaitable(Protocol[_T_co]):
@@ -229,7 +229,7 @@ class Coroutine(Awaitable[_V_co], Generic[_T_co, _T_contra, _V_co]):
__name__: str
__qualname__: str
@property
def cr_await(self) -> Optional[Any]: ...
def cr_await(self) -> Any | None: ...
@property
def cr_code(self) -> CodeType: ...
@property
@@ -241,11 +241,11 @@ class Coroutine(Awaitable[_V_co], Generic[_T_co, _T_contra, _V_co]):
@overload
@abstractmethod
def throw(
self, __typ: Type[BaseException], __val: Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ...
self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...
) -> _T_co: ...
@overload
@abstractmethod
def throw(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> _T_co: ...
def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ...
@abstractmethod
def close(self) -> None: ...
@@ -274,11 +274,11 @@ class AsyncGenerator(AsyncIterator[_T_co], Generic[_T_co, _T_contra]):
@overload
@abstractmethod
def athrow(
self, __typ: Type[BaseException], __val: Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ...
self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...
) -> Awaitable[_T_co]: ...
@overload
@abstractmethod
def athrow(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> Awaitable[_T_co]: ...
def athrow(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> Awaitable[_T_co]: ...
@abstractmethod
def aclose(self) -> Awaitable[None]: ...
@abstractmethod
@@ -358,9 +358,9 @@ class AbstractSet(_Collection[_T_co], Generic[_T_co]):
def __gt__(self, s: AbstractSet[Any]) -> bool: ...
def __ge__(self, s: AbstractSet[Any]) -> bool: ...
def __and__(self, s: AbstractSet[Any]) -> AbstractSet[_T_co]: ...
def __or__(self, s: AbstractSet[_T]) -> AbstractSet[Union[_T_co, _T]]: ...
def __or__(self, s: AbstractSet[_T]) -> AbstractSet[_T_co | _T]: ...
def __sub__(self, s: AbstractSet[Any]) -> AbstractSet[_T_co]: ...
def __xor__(self, s: AbstractSet[_T]) -> AbstractSet[Union[_T_co, _T]]: ...
def __xor__(self, s: AbstractSet[_T]) -> AbstractSet[_T_co | _T]: ...
def isdisjoint(self, other: Iterable[Any]) -> bool: ...
class MutableSet(AbstractSet[_T], Generic[_T]):
@@ -372,9 +372,9 @@ class MutableSet(AbstractSet[_T], Generic[_T]):
def clear(self) -> None: ...
def pop(self) -> _T: ...
def remove(self, value: _T) -> None: ...
def __ior__(self, s: AbstractSet[_S]) -> MutableSet[Union[_T, _S]]: ...
def __ior__(self, s: AbstractSet[_S]) -> MutableSet[_T | _S]: ...
def __iand__(self, s: AbstractSet[Any]) -> MutableSet[_T]: ...
def __ixor__(self, s: AbstractSet[_S]) -> MutableSet[Union[_T, _S]]: ...
def __ixor__(self, s: AbstractSet[_S]) -> MutableSet[_T | _S]: ...
def __isub__(self, s: AbstractSet[Any]) -> MutableSet[_T]: ...
class MappingView(Sized):
@@ -389,12 +389,12 @@ class ItemsView(MappingView, AbstractSet[Tuple[_KT_co, _VT_co]], Generic[_KT_co,
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[Union[Tuple[_KT_co, _VT_co], _T]]: ...
def __ror__(self, o: Iterable[_T]) -> Set[Union[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[Union[Tuple[_KT_co, _VT_co], _T]]: ...
def __rxor__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _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
@@ -404,12 +404,12 @@ class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]):
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[Union[_KT_co, _T]]: ...
def __ror__(self, o: Iterable[_T]) -> Set[Union[_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[Union[_KT_co, _T]]: ...
def __rxor__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _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
@@ -422,18 +422,15 @@ class ValuesView(MappingView, Iterable[_VT_co], Generic[_VT_co]):
class ContextManager(Protocol[_T_co]):
def __enter__(self) -> _T_co: ...
def __exit__(
self,
__exc_type: Optional[Type[BaseException]],
__exc_value: Optional[BaseException],
__traceback: Optional[TracebackType],
) -> Optional[bool]: ...
self, __exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None
) -> bool | None: ...
@runtime_checkable
class AsyncContextManager(Protocol[_T_co]):
def __aenter__(self) -> Awaitable[_T_co]: ...
def __aexit__(
self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], traceback: Optional[TracebackType]
) -> Awaitable[Optional[bool]]: ...
self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
) -> Awaitable[bool | None]: ...
class Mapping(_Collection[_KT], Generic[_KT, _VT_co]):
# TODO: We wish the key type could also be covariant, but that doesn't work,
@@ -442,9 +439,9 @@ class Mapping(_Collection[_KT], Generic[_KT, _VT_co]):
def __getitem__(self, k: _KT) -> _VT_co: ...
# Mixin methods
@overload
def get(self, key: _KT) -> Optional[_VT_co]: ...
def get(self, key: _KT) -> _VT_co | None: ...
@overload
def get(self, key: _KT, default: Union[_VT_co, _T]) -> Union[_VT_co, _T]: ...
def get(self, key: _KT, default: _VT_co | _T) -> _VT_co | _T: ...
def items(self) -> AbstractSet[Tuple[_KT, _VT_co]]: ...
def keys(self) -> AbstractSet[_KT]: ...
def values(self) -> ValuesView[_VT_co]: ...
@@ -459,7 +456,7 @@ class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]):
@overload
def pop(self, key: _KT) -> _VT: ...
@overload
def pop(self, key: _KT, default: Union[_VT, _T] = ...) -> Union[_VT, _T]: ...
def pop(self, key: _KT, default: _VT | _T = ...) -> _VT | _T: ...
def popitem(self) -> Tuple[_KT, _VT]: ...
def setdefault(self, key: _KT, default: _VT = ...) -> _VT: ...
# 'update' used to take a Union, but using overloading is better.
@@ -514,7 +511,7 @@ class IO(Iterator[AnyStr], Generic[AnyStr]):
@abstractmethod
def tell(self) -> int: ...
@abstractmethod
def truncate(self, size: Optional[int] = ...) -> int: ...
def truncate(self, size: int | None = ...) -> int: ...
@abstractmethod
def writable(self) -> bool: ...
@abstractmethod
@@ -529,8 +526,8 @@ class IO(Iterator[AnyStr], Generic[AnyStr]):
def __enter__(self) -> IO[AnyStr]: ...
@abstractmethod
def __exit__(
self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType]
) -> Optional[bool]: ...
self, t: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> bool | None: ...
class BinaryIO(IO[bytes]):
@abstractmethod
@@ -543,7 +540,7 @@ class TextIO(IO[str]):
@property
def encoding(self) -> str: ...
@property
def errors(self) -> Optional[str]: ...
def errors(self) -> str | None: ...
@property
def line_buffering(self) -> int: ... # int on PyPy, bool on CPython
@property
@@ -556,8 +553,8 @@ class ByteString(Sequence[int], metaclass=ABCMeta): ...
class Match(Generic[AnyStr]):
pos: int
endpos: int
lastindex: Optional[int]
lastgroup: Optional[AnyStr]
lastindex: int | None
lastgroup: AnyStr | None
string: AnyStr
# The regular expression object whose match() or search() method produced
@@ -583,9 +580,9 @@ class Match(Generic[AnyStr]):
def groupdict(self) -> dict[str, AnyStr | Any]: ...
@overload
def groupdict(self, default: _T) -> dict[str, AnyStr | _T]: ...
def start(self, __group: Union[int, str] = ...) -> int: ...
def end(self, __group: Union[int, str] = ...) -> int: ...
def span(self, __group: Union[int, str] = ...) -> Tuple[int, int]: ...
def start(self, __group: int | str = ...) -> int: ...
def end(self, __group: int | str = ...) -> int: ...
def span(self, __group: int | str = ...) -> Tuple[int, int]: ...
@property
def regs(self) -> Tuple[Tuple[int, int], ...]: ... # undocumented
# __getitem__() returns "AnyStr" or "AnyStr | None", depending on the pattern.
@@ -601,9 +598,9 @@ class Pattern(Generic[AnyStr]):
groupindex: Mapping[str, int]
groups: int
pattern: AnyStr
def search(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Optional[Match[AnyStr]]: ...
def match(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Optional[Match[AnyStr]]: ...
def fullmatch(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Optional[Match[AnyStr]]: ...
def search(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Match[AnyStr] | None: ...
def match(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Match[AnyStr] | None: ...
def fullmatch(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Match[AnyStr] | None: ...
def split(self, string: AnyStr, maxsplit: int = ...) -> list[AnyStr]: ...
def findall(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> list[Any]: ...
def finditer(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Iterator[Match[AnyStr]]: ...
@@ -640,18 +637,18 @@ else:
if sys.version_info >= (3, 9):
def get_type_hints(
obj: _get_type_hints_obj_allowed_types,
globalns: Optional[Dict[str, Any]] = ...,
localns: Optional[Dict[str, Any]] = ...,
globalns: Dict[str, Any] | None = ...,
localns: Dict[str, Any] | None = ...,
include_extras: bool = ...,
) -> Dict[str, Any]: ...
else:
def get_type_hints(
obj: _get_type_hints_obj_allowed_types, globalns: Optional[Dict[str, Any]] = ..., localns: Optional[Dict[str, Any]] = ...
obj: _get_type_hints_obj_allowed_types, globalns: Dict[str, Any] | None = ..., localns: Dict[str, Any] | None = ...
) -> Dict[str, Any]: ...
if sys.version_info >= (3, 8):
def get_origin(tp: Any) -> Optional[Any]: ...
def get_origin(tp: Any) -> Any | None: ...
def get_args(tp: Any) -> Tuple[Any, ...]: ...
@overload
@@ -704,13 +701,13 @@ if sys.version_info >= (3, 7):
__forward_arg__: str
__forward_code__: CodeType
__forward_evaluated__: bool
__forward_value__: Optional[Any]
__forward_value__: Any | None
__forward_is_argument__: bool
if sys.version_info >= (3, 10):
def __init__(self, arg: str, is_argument: bool = ..., module: Any | None = ...) -> None: ...
else:
def __init__(self, arg: str, is_argument: bool = ...) -> None: ...
def _evaluate(self, globalns: Optional[Dict[str, Any]], localns: Optional[Dict[str, Any]]) -> Optional[Any]: ...
def _evaluate(self, globalns: Dict[str, Any] | None, localns: Dict[str, Any] | None) -> Any | None: ...
def __eq__(self, other: Any) -> bool: ...
def __hash__(self) -> int: ...
def __repr__(self) -> str: ...