Use PEP 585 syntax wherever possible (#6717)

This commit is contained in:
Alex Waygood
2021-12-28 10:31:43 +00:00
committed by GitHub
parent e6cb341d94
commit 8d5d2520ac
237 changed files with 966 additions and 1069 deletions

View File

@@ -4,7 +4,7 @@ from _typeshed import Self
from abc import abstractmethod
from collections.abc import Container, Iterable, Iterator, Sequence
from logging import Logger
from typing import Any, Callable, Generic, Protocol, Set, TypeVar, overload
from typing import Any, Callable, Generic, Protocol, TypeVar, overload
from typing_extensions import SupportsIndex
if sys.version_info >= (3, 9):
@@ -76,7 +76,7 @@ class Executor:
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]]]):
class DoneAndNotDoneFutures(Sequence[set[Future[_T]]]):
done: set[Future[_T]]
not_done: set[Future[_T]]
def __new__(_cls, done: set[Future[_T]], not_done: set[Future[_T]]) -> DoneAndNotDoneFutures[_T]: ...

View File

@@ -5,7 +5,7 @@ from multiprocessing.context import BaseContext, Process
from multiprocessing.queues import Queue, SimpleQueue
from threading import Lock, Semaphore, Thread
from types import TracebackType
from typing import Any, Callable, Generic, Tuple, TypeVar
from typing import Any, Callable, Generic, TypeVar
from weakref import ref
from ._base import Executor, Future
@@ -37,7 +37,7 @@ class _ExceptionWithTraceback:
exc: BaseException
tb: TracebackType
def __init__(self, exc: BaseException, tb: TracebackType) -> None: ...
def __reduce__(self) -> str | Tuple[Any, ...]: ...
def __reduce__(self) -> str | tuple[Any, ...]: ...
def _rebuild_exc(exc: Exception, tb: str) -> Exception: ...
@@ -84,7 +84,7 @@ if sys.version_info >= (3, 7):
) -> None: ...
def _on_queue_feeder_error(self, e: Exception, obj: _CallItem) -> None: ...
def _get_chunks(*iterables: Any, chunksize: int) -> Generator[Tuple[Any, ...], None, None]: ...
def _get_chunks(*iterables: Any, chunksize: int) -> Generator[tuple[Any, ...], None, None]: ...
def _process_chunk(fn: Callable[..., Any], chunk: tuple[Any, None, None]) -> Generator[Any, None, None]: ...
def _sendback_result(
result_queue: SimpleQueue[_WorkItem[Any]], work_id: int, result: Any | None = ..., exception: Exception | None = ...
@@ -95,7 +95,7 @@ if sys.version_info >= (3, 7):
call_queue: Queue[_CallItem],
result_queue: SimpleQueue[_ResultItem],
initializer: Callable[..., None] | None,
initargs: Tuple[Any, ...],
initargs: tuple[Any, ...],
) -> None: ...
else:
@@ -139,7 +139,7 @@ else:
class ProcessPoolExecutor(Executor):
_mp_context: BaseContext | None = ...
_initializer: Callable[..., None] | None = ...
_initargs: Tuple[Any, ...] = ...
_initargs: tuple[Any, ...] = ...
_executor_manager_thread: _ThreadWakeup
_processes: MutableMapping[int, Process]
_shutdown_thread: bool
@@ -158,7 +158,7 @@ class ProcessPoolExecutor(Executor):
max_workers: int | None = ...,
mp_context: BaseContext | None = ...,
initializer: Callable[..., None] | None = ...,
initargs: Tuple[Any, ...] = ...,
initargs: tuple[Any, ...] = ...,
) -> None: ...
else:
def __init__(self, max_workers: int | None = ...) -> None: ...

View File

@@ -2,7 +2,7 @@ import queue
import sys
from collections.abc import Iterable, Mapping, Set as AbstractSet
from threading import Lock, Semaphore, Thread
from typing import Any, Callable, Generic, Tuple, TypeVar
from typing import Any, Callable, Generic, TypeVar
from weakref import ref
from ._base import Executor, Future
@@ -33,7 +33,7 @@ if sys.version_info >= (3, 7):
executor_reference: ref[Any],
work_queue: queue.SimpleQueue[Any],
initializer: Callable[..., None],
initargs: Tuple[Any, ...],
initargs: tuple[Any, ...],
) -> None: ...
else:
@@ -52,7 +52,7 @@ class ThreadPoolExecutor(Executor):
_shutdown_lock: Lock
_thread_name_prefix: str | None = ...
_initializer: Callable[..., None] | None = ...
_initargs: Tuple[Any, ...] = ...
_initargs: tuple[Any, ...] = ...
if sys.version_info >= (3, 7):
_work_queue: queue.SimpleQueue[_WorkItem[Any]]
else:
@@ -63,7 +63,7 @@ class ThreadPoolExecutor(Executor):
max_workers: int | None = ...,
thread_name_prefix: str = ...,
initializer: Callable[..., None] | None = ...,
initargs: Tuple[Any, ...] = ...,
initargs: tuple[Any, ...] = ...,
) -> None: ...
else:
def __init__(self, max_workers: int | None = ..., thread_name_prefix: str = ...) -> None: ...