diff --git a/stdlib/multiprocessing/pool.pyi b/stdlib/multiprocessing/pool.pyi index 63f8d6d03..20cfc5963 100644 --- a/stdlib/multiprocessing/pool.pyi +++ b/stdlib/multiprocessing/pool.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import Self -from typing import Any, Callable, ContextManager, Generic, Iterable, Iterator, List, Mapping, TypeVar +from typing import Any, Callable, ContextManager, Dict, Generic, Iterable, Iterator, List, Mapping, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias @@ -10,12 +10,17 @@ _S = TypeVar("_S") _T = TypeVar("_T") class ApplyResult(Generic[_T]): - def __init__( - self, - pool: Pool, - callback: Callable[[_T], None] | None = ..., - error_callback: Callable[[BaseException], None] | None = ..., - ) -> None: ... + if sys.version_info >= (3, 8): + def __init__( + self, pool: Pool, callback: Callable[[_T], None] | None, error_callback: Callable[[BaseException], None] | None + ) -> None: ... + else: + def __init__( + self, + cache: Dict[int, ApplyResult[Any]], + callback: Callable[[_T], None] | None, + error_callback: Callable[[BaseException], None] | None, + ) -> None: ... def get(self, timeout: float | None = ...) -> _T: ... def wait(self, timeout: float | None = ...) -> None: ... def ready(self) -> bool: ... @@ -26,9 +31,31 @@ class ApplyResult(Generic[_T]): # alias created during issue #17805 AsyncResult = ApplyResult -class MapResult(ApplyResult[List[_T]]): ... +class MapResult(ApplyResult[List[_T]]): + if sys.version_info >= (3, 8): + def __init__( + self, + pool: Pool, + chunksize: int, + length: int, + callback: Callable[[List[_T]], None] | None, + error_callback: Callable[[BaseException], None] | None, + ) -> None: ... + else: + def __init__( + self, + cache: Dict[int, ApplyResult[Any]], + chunksize: int, + length: int, + callback: Callable[[List[_T]], None] | None, + error_callback: Callable[[BaseException], None] | None, + ) -> None: ... class IMapIterator(Iterator[_T]): + if sys.version_info >= (3, 8): + def __init__(self, pool: Pool) -> None: ... + else: + def __init__(self, cache: Dict[int, IMapIterator[Any]]) -> None: ... def __iter__(self: _S) -> _S: ... def next(self, timeout: float | None = ...) -> _T: ... def __next__(self, timeout: float | None = ...) -> _T: ... diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index 70ecd06ee..758834b33 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -142,9 +142,6 @@ multiprocessing.managers.SyncManager.Event multiprocessing.managers.SyncManager.Lock multiprocessing.managers.SyncManager.Namespace multiprocessing.managers.SyncManager.RLock -multiprocessing.pool.ApplyResult.__init__ -multiprocessing.pool.IMapIterator.__init__ -multiprocessing.pool.MapResult.__init__ multiprocessing.queues.JoinableQueue.__init__ multiprocessing.queues.Queue.__init__ multiprocessing.queues.Queue.put_nowait