|
1 | 1 | import sys |
2 | 2 | import threading |
3 | 3 | from _typeshed import Unused |
4 | | -from collections.abc import Callable, Iterable, Iterator, Sequence |
| 4 | +from collections.abc import Callable, Iterable, Iterator |
5 | 5 | from logging import Logger |
6 | 6 | from types import TracebackType |
7 | | -from typing import Any, Generic, TypeVar, overload |
8 | | -from typing_extensions import Literal, ParamSpec, Self, SupportsIndex |
| 7 | +from typing import Any, Generic, NamedTuple, TypeVar |
| 8 | +from typing_extensions import Literal, ParamSpec, Self |
9 | 9 |
|
10 | 10 | if sys.version_info >= (3, 9): |
11 | 11 | from types import GenericAlias |
@@ -69,20 +69,9 @@ class Executor: |
69 | 69 |
|
70 | 70 | def as_completed(fs: Iterable[Future[_T]], timeout: float | None = None) -> Iterator[Future[_T]]: ... |
71 | 71 |
|
72 | | -# Ideally this would be a namedtuple, but mypy doesn't support generic tuple types. See #1976 |
73 | | -class DoneAndNotDoneFutures(Sequence[set[Future[_T]]]): |
74 | | - if sys.version_info >= (3, 10): |
75 | | - __match_args__ = ("done", "not_done") |
76 | | - @property |
77 | | - def done(self) -> set[Future[_T]]: ... |
78 | | - @property |
79 | | - def not_done(self) -> set[Future[_T]]: ... |
80 | | - def __new__(_cls, done: set[Future[_T]], not_done: set[Future[_T]]) -> DoneAndNotDoneFutures[_T]: ... |
81 | | - def __len__(self) -> int: ... |
82 | | - @overload |
83 | | - def __getitem__(self, __i: SupportsIndex) -> set[Future[_T]]: ... |
84 | | - @overload |
85 | | - def __getitem__(self, __s: slice) -> DoneAndNotDoneFutures[_T]: ... |
| 72 | +class DoneAndNotDoneFutures(NamedTuple, Generic[_T]): |
| 73 | + done: set[Future[_T]] |
| 74 | + not_done: set[Future[_T]] |
86 | 75 |
|
87 | 76 | def wait( |
88 | 77 | fs: Iterable[Future[_T]], timeout: float | None = None, return_when: str = "ALL_COMPLETED" |
|
0 commit comments