Fix set annotations in concurrent.futures._base (#6034)

This commit is contained in:
Sebastian Rittau
2021-09-14 10:50:20 +02:00
committed by GitHub
parent b562d233ae
commit ca38856670

View File

@@ -2,9 +2,9 @@ import sys
import threading
from _typeshed import Self
from abc import abstractmethod
from collections.abc import Container, Iterable, Iterator, Sequence, Set
from collections.abc import Container, Iterable, Iterator, Sequence
from logging import Logger
from typing import Any, Callable, Generic, Protocol, TypeVar, overload
from typing import Any, Callable, Generic, Protocol, Set, TypeVar, overload
if sys.version_info >= (3, 9):
from types import GenericAlias
@@ -76,12 +76,12 @@ def as_completed(fs: Iterable[Future[_T]], timeout: float | None = ...) -> Itera
# Ideally this would be a namedtuple, but mypy doesn't support generic tuple types. See #1976
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]: ...
done: set[Future[_T]]
not_done: set[Future[_T]]
def __new__(_cls, done: set[Future[_T]], not_done: set[Future[_T]]) -> DoneAndNotDoneFutures[_T]: ...
def __len__(self) -> int: ...
@overload
def __getitem__(self, i: int) -> Set[Future[_T]]: ...
def __getitem__(self, i: int) -> set[Future[_T]]: ...
@overload
def __getitem__(self, s: slice) -> DoneAndNotDoneFutures[_T]: ...