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

@@ -3,21 +3,7 @@ import threading
from _typeshed import Self
from abc import abstractmethod
from logging import Logger
from typing import (
Any,
Callable,
Container,
Generic,
Iterable,
Iterator,
List,
Optional,
Protocol,
Sequence,
Set,
TypeVar,
overload,
)
from typing import Any, Callable, Container, Generic, Iterable, Iterator, List, Protocol, Sequence, Set, TypeVar, overload
if sys.version_info >= (3, 9):
from types import GenericAlias
@@ -60,11 +46,11 @@ class Future(Generic[_T]):
def running(self) -> bool: ...
def done(self) -> bool: ...
def add_done_callback(self, fn: Callable[[Future[_T]], Any]) -> None: ...
def result(self, timeout: Optional[float] = ...) -> _T: ...
def result(self, timeout: float | None = ...) -> _T: ...
def set_running_or_notify_cancel(self) -> bool: ...
def set_result(self, result: _T) -> None: ...
def exception(self, timeout: Optional[float] = ...) -> Optional[BaseException]: ...
def set_exception(self, exception: Optional[BaseException]) -> None: ...
def exception(self, timeout: float | None = ...) -> BaseException | None: ...
def set_exception(self, exception: BaseException | None) -> None: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
@@ -74,16 +60,16 @@ class Executor:
else:
def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ...
def map(
self, fn: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ..., chunksize: int = ...
self, fn: Callable[..., _T], *iterables: Iterable[Any], timeout: float | None = ..., chunksize: int = ...
) -> Iterator[_T]: ...
if sys.version_info >= (3, 9):
def shutdown(self, wait: bool = ..., *, cancel_futures: bool = ...) -> None: ...
else:
def shutdown(self, wait: bool = ...) -> None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> Optional[bool]: ...
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool | None: ...
def as_completed(fs: Iterable[Future[_T]], timeout: Optional[float] = ...) -> Iterator[Future[_T]]: ...
def as_completed(fs: Iterable[Future[_T]], timeout: float | None = ...) -> Iterator[Future[_T]]: ...
# Ideally this would be a namedtuple, but mypy doesn't support generic tuple types. See #1976
class DoneAndNotDoneFutures(Sequence[Set[Future[_T]]]):
@@ -96,7 +82,7 @@ class DoneAndNotDoneFutures(Sequence[Set[Future[_T]]]):
@overload
def __getitem__(self, s: slice) -> DoneAndNotDoneFutures[_T]: ...
def wait(fs: Iterable[Future[_T]], timeout: Optional[float] = ..., return_when: str = ...) -> DoneAndNotDoneFutures[_T]: ...
def wait(fs: Iterable[Future[_T]], timeout: float | None = ..., return_when: str = ...) -> DoneAndNotDoneFutures[_T]: ...
class _Waiter:
event: threading.Event

View File

@@ -1,5 +1,5 @@
import sys
from typing import Any, Callable, Optional, Tuple
from typing import Any, Callable, Tuple
from ._base import Executor
@@ -17,12 +17,12 @@ if sys.version_info >= (3, 7):
class ProcessPoolExecutor(Executor):
def __init__(
self,
max_workers: Optional[int] = ...,
mp_context: Optional[BaseContext] = ...,
initializer: Optional[Callable[..., None]] = ...,
max_workers: int | None = ...,
mp_context: BaseContext | None = ...,
initializer: Callable[..., None] | None = ...,
initargs: Tuple[Any, ...] = ...,
) -> None: ...
else:
class ProcessPoolExecutor(Executor):
def __init__(self, max_workers: Optional[int] = ...) -> None: ...
def __init__(self, max_workers: int | None = ...) -> None: ...

View File

@@ -1,6 +1,6 @@
import queue
import sys
from typing import Any, Callable, Generic, Iterable, Mapping, Optional, Tuple, TypeVar
from typing import Any, Callable, Generic, Iterable, Mapping, Tuple, TypeVar
from ._base import Executor, Future
@@ -21,13 +21,13 @@ class ThreadPoolExecutor(Executor):
if sys.version_info >= (3, 7):
def __init__(
self,
max_workers: Optional[int] = ...,
max_workers: int | None = ...,
thread_name_prefix: str = ...,
initializer: Optional[Callable[..., None]] = ...,
initializer: Callable[..., None] | None = ...,
initargs: Tuple[Any, ...] = ...,
) -> None: ...
else:
def __init__(self, max_workers: Optional[int] = ..., thread_name_prefix: str = ...) -> None: ...
def __init__(self, max_workers: int | None = ..., thread_name_prefix: str = ...) -> None: ...
class _WorkItem(Generic[_S]):
future: Future[_S]