Closed
Labels
stubs: false positiveType checkers report false errorsType checkers report false errors
Description
Currently, the type of concurrent.futures.wait in typeshed is as follows:
def wait(fs: Iterable[Future[_T]], timeout: Optional[float] = ..., return_when: str = ...) -> Tuple[Set[Future[_T]],
Set[Future[_T]]]: ...According to Python's documentation:
Returns a named 2-tuple of sets. The first set, named done, contains the futures that completed (finished or cancelled futures) before the wait completed. The second set, named not_done, contains the futures that did not complete (pending or running futures).
So the type should really be:
class DoneAndNotDoneFutures(Generic[_T], NamedTuple):
done: Set[Future[_T]]
not_done: Set[Future[_T]]
def wait(fs: Iterable[Future[_T]], timeout: Optional[float] = ..., return_when: str = ...) -> DoneAndNotDoneFutures[_T]: ...(the name of the NamedTuple is taken from CPython's implementation of concurrent.futures)
Unfortunately, generic NamedTuples are not currently supported by mypy, so that change would break the tests.
Metadata
Metadata
Assignees
Labels
stubs: false positiveType checkers report false errorsType checkers report false errors
Activity
srittau commentedon Oct 17, 2019
Thank you for the good analysis. PR welcome!
JelleZijlstra commentedon Oct 17, 2019
Duplicate of #1976.