Big diff: Use new "|" union syntax (#5872)

This commit is contained in:
Akuli
2021-08-08 12:05:21 +03:00
committed by GitHub
parent b9adb7a874
commit ee487304d7
578 changed files with 8080 additions and 8966 deletions

View File

@@ -20,7 +20,7 @@ from multiprocessing.process import active_children as active_children, current_
# multiprocessing.queues or the aliases defined below. See #4266 for discussion.
from multiprocessing.queues import JoinableQueue as JoinableQueue, Queue as Queue, SimpleQueue as SimpleQueue
from multiprocessing.spawn import freeze_support as freeze_support
from typing import Any, Optional, Union, overload
from typing import Any, Union, overload
from typing_extensions import Literal
if sys.version_info >= (3, 8):
@@ -60,32 +60,32 @@ RawArray = context._default_context.RawArray
Value = context._default_context.Value
Array = context._default_context.Array
def Barrier(parties: int, action: Optional[Callable[..., Any]] = ..., timeout: Optional[float] = ...) -> _BarrierType: ...
def Barrier(parties: int, action: Callable[..., Any] | None = ..., timeout: float | None = ...) -> _BarrierType: ...
def BoundedSemaphore(value: int = ...) -> _BoundedSemaphoreType: ...
def Condition(lock: Optional[_LockLike] = ...) -> _ConditionType: ...
def Condition(lock: _LockLike | None = ...) -> _ConditionType: ...
def Event() -> _EventType: ...
def Lock() -> _LockType: ...
def RLock() -> _RLockType: ...
def Semaphore(value: int = ...) -> _SemaphoreType: ...
def Pipe(duplex: bool = ...) -> tuple[connection.Connection, connection.Connection]: ...
def Pool(
processes: Optional[int] = ...,
initializer: Optional[Callable[..., Any]] = ...,
processes: int | None = ...,
initializer: Callable[..., Any] | None = ...,
initargs: Iterable[Any] = ...,
maxtasksperchild: Optional[int] = ...,
maxtasksperchild: int | None = ...,
) -> pool.Pool: ...
# ----- multiprocessing function stubs -----
def allow_connection_pickling() -> None: ...
def cpu_count() -> int: ...
def get_logger() -> Logger: ...
def log_to_stderr(level: Optional[Union[str, int]] = ...) -> Logger: ...
def log_to_stderr(level: str | int | None = ...) -> Logger: ...
def Manager() -> SyncManager: ...
def set_executable(executable: str) -> None: ...
def set_forkserver_preload(module_names: list[str]) -> None: ...
def get_all_start_methods() -> list[str]: ...
def get_start_method(allow_none: bool = ...) -> Optional[str]: ...
def set_start_method(method: str, force: Optional[bool] = ...) -> None: ...
def get_start_method(allow_none: bool = ...) -> str | None: ...
def set_start_method(method: str, force: bool | None = ...) -> None: ...
if sys.platform != "win32":
@overload

View File

@@ -2,7 +2,7 @@ import socket
import sys
import types
from _typeshed import Self
from typing import Any, Iterable, List, Optional, Tuple, Type, Union
from typing import Any, Iterable, List, Tuple, Type, Union
if sys.version_info >= (3, 8):
from typing import SupportsIndex
@@ -23,15 +23,15 @@ class _ConnectionBase:
def writable(self) -> bool: ... # undocumented
def fileno(self) -> int: ...
def close(self) -> None: ...
def send_bytes(self, buf: bytes, offset: int = ..., size: Optional[int] = ...) -> None: ...
def send_bytes(self, buf: bytes, offset: int = ..., size: int | None = ...) -> None: ...
def send(self, obj: Any) -> None: ...
def recv_bytes(self, maxlength: Optional[int] = ...) -> bytes: ...
def recv_bytes(self, maxlength: int | None = ...) -> bytes: ...
def recv_bytes_into(self, buf: Any, offset: int = ...) -> int: ...
def recv(self) -> Any: ...
def poll(self, timeout: Optional[float] = ...) -> bool: ...
def poll(self, timeout: float | None = ...) -> bool: ...
def __enter__(self: Self) -> Self: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], exc_tb: Optional[types.TracebackType]
self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None
) -> None: ...
class Connection(_ConnectionBase): ...
@@ -41,23 +41,23 @@ if sys.platform == "win32":
class Listener:
def __init__(
self, address: Optional[_Address] = ..., family: Optional[str] = ..., backlog: int = ..., authkey: Optional[bytes] = ...
self, address: _Address | None = ..., family: str | None = ..., backlog: int = ..., authkey: bytes | None = ...
) -> None: ...
def accept(self) -> Connection: ...
def close(self) -> None: ...
@property
def address(self) -> _Address: ...
@property
def last_accepted(self) -> Optional[_Address]: ...
def last_accepted(self) -> _Address | None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], exc_tb: Optional[types.TracebackType]
self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None
) -> None: ...
def deliver_challenge(connection: Connection, authkey: bytes) -> None: ...
def answer_challenge(connection: Connection, authkey: bytes) -> None: ...
def wait(
object_list: Iterable[Union[Connection, socket.socket, int]], timeout: Optional[float] = ...
) -> List[Union[Connection, socket.socket, int]]: ...
def Client(address: _Address, family: Optional[str] = ..., authkey: Optional[bytes] = ...) -> Connection: ...
object_list: Iterable[Connection | socket.socket | int], timeout: float | None = ...
) -> List[Connection | socket.socket | int]: ...
def Client(address: _Address, family: str | None = ..., authkey: bytes | None = ...) -> Connection: ...
def Pipe(duplex: bool = ...) -> Tuple[Connection, Connection]: ...

View File

@@ -7,7 +7,7 @@ from logging import Logger
from multiprocessing import queues, synchronize
from multiprocessing.process import BaseProcess
from multiprocessing.sharedctypes import SynchronizedArray, SynchronizedBase
from typing import Any, Optional, Type, TypeVar, Union, overload
from typing import Any, Type, TypeVar, Union, overload
from typing_extensions import Literal
_LockLike = Union[synchronize.Lock, synchronize.RLock]
@@ -31,7 +31,7 @@ class BaseContext(object):
def current_process() -> BaseProcess: ...
if sys.version_info >= (3, 8):
@staticmethod
def parent_process() -> Optional[BaseProcess]: ...
def parent_process() -> BaseProcess | None: ...
@staticmethod
def active_children() -> list[BaseProcess]: ...
def cpu_count(self) -> int: ...
@@ -40,10 +40,10 @@ class BaseContext(object):
# TODO: change return to Pipe once a stub exists in multiprocessing.connection
def Pipe(self, duplex: bool = ...) -> Any: ...
def Barrier(
self, parties: int, action: Optional[Callable[..., Any]] = ..., timeout: Optional[float] = ...
self, parties: int, action: Callable[..., Any] | None = ..., timeout: float | None = ...
) -> synchronize.Barrier: ...
def BoundedSemaphore(self, value: int = ...) -> synchronize.BoundedSemaphore: ...
def Condition(self, lock: Optional[_LockLike] = ...) -> synchronize.Condition: ...
def Condition(self, lock: _LockLike | None = ...) -> synchronize.Condition: ...
def Event(self) -> synchronize.Event: ...
def Lock(self) -> synchronize.Lock: ...
def RLock(self) -> synchronize.RLock: ...
@@ -53,54 +53,44 @@ class BaseContext(object):
def SimpleQueue(self) -> queues.SimpleQueue[Any]: ...
def Pool(
self,
processes: Optional[int] = ...,
initializer: Optional[Callable[..., Any]] = ...,
processes: int | None = ...,
initializer: Callable[..., Any] | None = ...,
initargs: Iterable[Any] = ...,
maxtasksperchild: Optional[int] = ...,
maxtasksperchild: int | None = ...,
) -> multiprocessing.pool.Pool: ...
@overload
def RawValue(self, typecode_or_type: Type[_CT], *args: Any) -> _CT: ...
@overload
def RawValue(self, typecode_or_type: str, *args: Any) -> Any: ...
@overload
def RawArray(self, typecode_or_type: Type[_CT], size_or_initializer: Union[int, Sequence[Any]]) -> ctypes.Array[_CT]: ...
def RawArray(self, typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any]) -> ctypes.Array[_CT]: ...
@overload
def RawArray(self, typecode_or_type: str, size_or_initializer: Union[int, Sequence[Any]]) -> Any: ...
def RawArray(self, typecode_or_type: str, size_or_initializer: int | Sequence[Any]) -> Any: ...
@overload
def Value(self, typecode_or_type: Type[_CT], *args: Any, lock: Literal[False]) -> _CT: ...
@overload
def Value(self, typecode_or_type: Type[_CT], *args: Any, lock: Union[Literal[True], _LockLike]) -> SynchronizedBase[_CT]: ...
def Value(self, typecode_or_type: Type[_CT], *args: Any, lock: Literal[True] | _LockLike) -> SynchronizedBase[_CT]: ...
@overload
def Value(self, typecode_or_type: str, *args: Any, lock: Union[Literal[True], _LockLike]) -> SynchronizedBase[Any]: ...
def Value(self, typecode_or_type: str, *args: Any, lock: Literal[True] | _LockLike) -> SynchronizedBase[Any]: ...
@overload
def Value(self, typecode_or_type: Union[str, Type[_CData]], *args: Any, lock: Union[bool, _LockLike] = ...) -> Any: ...
def Value(self, typecode_or_type: str | Type[_CData], *args: Any, lock: bool | _LockLike = ...) -> Any: ...
@overload
def Array(self, typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False]) -> _CT: ...
@overload
def Array(
self, typecode_or_type: Type[_CT], size_or_initializer: Union[int, Sequence[Any]], *, lock: Literal[False]
) -> _CT: ...
@overload
def Array(
self,
typecode_or_type: Type[_CT],
size_or_initializer: Union[int, Sequence[Any]],
*,
lock: Union[Literal[True], _LockLike],
self, typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike
) -> SynchronizedArray[_CT]: ...
@overload
def Array(
self, typecode_or_type: str, size_or_initializer: Union[int, Sequence[Any]], *, lock: Union[Literal[True], _LockLike]
self, typecode_or_type: str, size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike
) -> SynchronizedArray[Any]: ...
@overload
def Array(
self,
typecode_or_type: Union[str, Type[_CData]],
size_or_initializer: Union[int, Sequence[Any]],
*,
lock: Union[bool, _LockLike] = ...,
self, typecode_or_type: str | Type[_CData], size_or_initializer: int | Sequence[Any], *, lock: bool | _LockLike = ...
) -> Any: ...
def freeze_support(self) -> None: ...
def get_logger(self) -> Logger: ...
def log_to_stderr(self, level: Optional[str] = ...) -> Logger: ...
def log_to_stderr(self, level: str | None = ...) -> Logger: ...
def allow_connection_pickling(self) -> None: ...
def set_executable(self, executable: str) -> None: ...
def set_forkserver_preload(self, module_names: list[str]) -> None: ...
@@ -123,7 +113,7 @@ class BaseContext(object):
@overload
def get_context(self, method: str) -> BaseContext: ...
def get_start_method(self, allow_none: bool = ...) -> str: ...
def set_start_method(self, method: Optional[str], force: bool = ...) -> None: ...
def set_start_method(self, method: str | None, force: bool = ...) -> None: ...
@property
def reducer(self) -> str: ...
@reducer.setter
@@ -131,14 +121,14 @@ class BaseContext(object):
def _check_available(self) -> None: ...
class Process(BaseProcess):
_start_method: Optional[str]
_start_method: str | None
@staticmethod
def _Popen(process_obj: BaseProcess) -> DefaultContext: ...
class DefaultContext(BaseContext):
Process: Type[multiprocessing.Process]
def __init__(self, context: BaseContext) -> None: ...
def set_start_method(self, method: Optional[str], force: bool = ...) -> None: ...
def set_start_method(self, method: str | None, force: bool = ...) -> None: ...
def get_start_method(self, allow_none: bool = ...) -> str: ...
def get_all_start_methods(self) -> list[str]: ...
@@ -177,6 +167,6 @@ else:
Process: Type[SpawnProcess]
def _force_start_method(method: str) -> None: ...
def get_spawning_popen() -> Optional[Any]: ...
def get_spawning_popen() -> Any | None: ...
def set_spawning_popen(popen: Any) -> None: ...
def assert_spawning(obj: Any) -> None: ...

View File

@@ -2,7 +2,7 @@ import array
import threading
import weakref
from queue import Queue as Queue
from typing import Any, Callable, Iterable, List, Mapping, Optional, Sequence
from typing import Any, Callable, Iterable, List, Mapping, Sequence
JoinableQueue = Queue
Barrier = threading.Barrier
@@ -18,12 +18,12 @@ class DummyProcess(threading.Thread):
_parent: threading.Thread
_pid: None
_start_called: int
exitcode: Optional[int]
exitcode: int | None
def __init__(
self,
group: Any = ...,
target: Optional[Callable[..., Any]] = ...,
name: Optional[str] = ...,
target: Callable[..., Any] | None = ...,
name: str | None = ...,
args: Iterable[Any] = ...,
kwargs: Mapping[str, Any] = ...,
) -> None: ...
@@ -43,9 +43,7 @@ class Value:
def Array(typecode: Any, sequence: Sequence[Any], lock: Any = ...) -> array.array[Any]: ...
def Manager() -> Any: ...
def Pool(
processes: Optional[int] = ..., initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ...
) -> Any: ...
def Pool(processes: int | None = ..., initializer: Callable[..., Any] | None = ..., initargs: Iterable[Any] = ...) -> Any: ...
def active_children() -> List[Any]: ...
def current_process() -> threading.Thread: ...
def freeze_support() -> None: ...

View File

@@ -1,7 +1,7 @@
from _typeshed import Self
from queue import Queue
from types import TracebackType
from typing import Any, List, Optional, Tuple, Type, Union
from typing import Any, List, Tuple, Type, Union
families: List[None]
@@ -16,21 +16,21 @@ class Connection(object):
send_bytes: Any
def __enter__(self: Self) -> Self: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
def __init__(self, _in: Any, _out: Any) -> None: ...
def close(self) -> None: ...
def poll(self, timeout: float = ...) -> bool: ...
class Listener(object):
_backlog_queue: Optional[Queue[Any]]
_backlog_queue: Queue[Any] | None
@property
def address(self) -> Optional[Queue[Any]]: ...
def address(self) -> Queue[Any] | None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
def __init__(self, address: Optional[_Address] = ..., family: Optional[int] = ..., backlog: int = ...) -> None: ...
def __init__(self, address: _Address | None = ..., family: int | None = ..., backlog: int = ...) -> None: ...
def accept(self) -> Connection: ...
def close(self) -> None: ...

View File

@@ -3,22 +3,7 @@
import queue
import sys
import threading
from typing import (
Any,
AnyStr,
Callable,
ContextManager,
Dict,
Generic,
Iterable,
List,
Mapping,
Optional,
Sequence,
Tuple,
TypeVar,
Union,
)
from typing import Any, AnyStr, Callable, ContextManager, Dict, Generic, Iterable, List, Mapping, Sequence, Tuple, TypeVar
from .connection import Connection
from .context import BaseContext
@@ -44,19 +29,13 @@ class Namespace:
_Namespace = Namespace
class Token(object):
typeid: Optional[Union[str, bytes]]
address: Tuple[Union[str, bytes], int]
id: Optional[Union[str, bytes, int]]
def __init__(
self, typeid: Optional[Union[bytes, str]], address: Tuple[Union[str, bytes], int], id: Optional[Union[str, bytes, int]]
) -> None: ...
typeid: str | bytes | None
address: Tuple[str | bytes, int]
id: str | bytes | int | None
def __init__(self, typeid: bytes | str | None, address: Tuple[str | bytes, int], id: str | bytes | int | None) -> None: ...
def __repr__(self) -> str: ...
def __getstate__(
self,
) -> Tuple[Optional[Union[str, bytes]], Tuple[Union[str, bytes], int], Optional[Union[str, bytes, int]]]: ...
def __setstate__(
self, state: Tuple[Optional[Union[str, bytes]], Tuple[Union[str, bytes], int], Optional[Union[str, bytes, int]]]
) -> None: ...
def __getstate__(self) -> Tuple[str | bytes | None, Tuple[str | bytes, int], str | bytes | int | None]: ...
def __setstate__(self, state: Tuple[str | bytes | None, Tuple[str | bytes, int], str | bytes | int | None]) -> None: ...
class BaseProxy(object):
_address_to_local: Dict[Any, Any]
@@ -66,12 +45,12 @@ class BaseProxy(object):
token: Any,
serializer: str,
manager: Any = ...,
authkey: Optional[AnyStr] = ...,
authkey: AnyStr | None = ...,
exposed: Any = ...,
incref: bool = ...,
manager_owned: bool = ...,
) -> None: ...
def __deepcopy__(self, memo: Optional[Any]) -> Any: ...
def __deepcopy__(self, memo: Any | None) -> Any: ...
def _callmethod(self, methodname: str, args: Tuple[Any, ...] = ..., kwds: Dict[Any, Any] = ...) -> None: ...
def _getvalue(self) -> Any: ...
def __reduce__(self) -> Tuple[Any, Tuple[Any, Any, str, Dict[Any, Any]]]: ...
@@ -94,27 +73,23 @@ class Server:
class BaseManager(ContextManager[BaseManager]):
def __init__(
self,
address: Optional[Any] = ...,
authkey: Optional[bytes] = ...,
serializer: str = ...,
ctx: Optional[BaseContext] = ...,
self, address: Any | None = ..., authkey: bytes | None = ..., serializer: str = ..., ctx: BaseContext | None = ...
) -> None: ...
def get_server(self) -> Server: ...
def connect(self) -> None: ...
def start(self, initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ...) -> None: ...
def start(self, initializer: Callable[..., Any] | None = ..., initargs: Iterable[Any] = ...) -> None: ...
def shutdown(self) -> None: ... # only available after start() was called
def join(self, timeout: Optional[float] = ...) -> None: ... # undocumented
def join(self, timeout: float | None = ...) -> None: ... # undocumented
@property
def address(self) -> Any: ...
@classmethod
def register(
cls,
typeid: str,
callable: Optional[Callable[..., Any]] = ...,
callable: Callable[..., Any] | None = ...,
proxytype: Any = ...,
exposed: Optional[Sequence[str]] = ...,
method_to_typeid: Optional[Mapping[str, str]] = ...,
exposed: Sequence[str] | None = ...,
method_to_typeid: Mapping[str, str] | None = ...,
create_method: bool = ...,
) -> None: ...
@@ -139,4 +114,4 @@ if sys.version_info >= (3, 8):
class SharedMemoryManager(BaseManager):
def get_server(self) -> SharedMemoryServer: ...
def SharedMemory(self, size: int) -> _SharedMemory: ...
def ShareableList(self, sequence: Optional[Iterable[_SLT]]) -> _ShareableList[_SLT]: ...
def ShareableList(self, sequence: Iterable[_SLT] | None) -> _ShareableList[_SLT]: ...

View File

@@ -1,6 +1,6 @@
import sys
from _typeshed import Self
from typing import Any, Callable, ContextManager, Generic, Iterable, Iterator, List, Mapping, Optional, TypeVar
from typing import Any, Callable, ContextManager, Generic, Iterable, Iterator, List, Mapping, TypeVar
if sys.version_info >= (3, 9):
from types import GenericAlias
@@ -13,11 +13,11 @@ class ApplyResult(Generic[_T]):
def __init__(
self,
pool: Pool,
callback: Optional[Callable[[_T], None]] = ...,
error_callback: Optional[Callable[[BaseException], None]] = ...,
callback: Callable[[_T], None] | None = ...,
error_callback: Callable[[BaseException], None] | None = ...,
) -> None: ...
def get(self, timeout: Optional[float] = ...) -> _T: ...
def wait(self, timeout: Optional[float] = ...) -> None: ...
def get(self, timeout: float | None = ...) -> _T: ...
def wait(self, timeout: float | None = ...) -> None: ...
def ready(self) -> bool: ...
def successful(self) -> bool: ...
if sys.version_info >= (3, 9):
@@ -30,19 +30,19 @@ class MapResult(ApplyResult[List[_T]]): ...
class IMapIterator(Iterator[_T]):
def __iter__(self: _S) -> _S: ...
def next(self, timeout: Optional[float] = ...) -> _T: ...
def __next__(self, timeout: Optional[float] = ...) -> _T: ...
def next(self, timeout: float | None = ...) -> _T: ...
def __next__(self, timeout: float | None = ...) -> _T: ...
class IMapUnorderedIterator(IMapIterator[_T]): ...
class Pool(ContextManager[Pool]):
def __init__(
self,
processes: Optional[int] = ...,
initializer: Optional[Callable[..., None]] = ...,
processes: int | None = ...,
initializer: Callable[..., None] | None = ...,
initargs: Iterable[Any] = ...,
maxtasksperchild: Optional[int] = ...,
context: Optional[Any] = ...,
maxtasksperchild: int | None = ...,
context: Any | None = ...,
) -> None: ...
def apply(self, func: Callable[..., _T], args: Iterable[Any] = ..., kwds: Mapping[str, Any] = ...) -> _T: ...
def apply_async(
@@ -50,30 +50,30 @@ class Pool(ContextManager[Pool]):
func: Callable[..., _T],
args: Iterable[Any] = ...,
kwds: Mapping[str, Any] = ...,
callback: Optional[Callable[[_T], None]] = ...,
error_callback: Optional[Callable[[BaseException], None]] = ...,
callback: Callable[[_T], None] | None = ...,
error_callback: Callable[[BaseException], None] | None = ...,
) -> AsyncResult[_T]: ...
def map(self, func: Callable[[_S], _T], iterable: Iterable[_S], chunksize: Optional[int] = ...) -> List[_T]: ...
def map(self, func: Callable[[_S], _T], iterable: Iterable[_S], chunksize: int | None = ...) -> List[_T]: ...
def map_async(
self,
func: Callable[[_S], _T],
iterable: Iterable[_S],
chunksize: Optional[int] = ...,
callback: Optional[Callable[[_T], None]] = ...,
error_callback: Optional[Callable[[BaseException], None]] = ...,
chunksize: int | None = ...,
callback: Callable[[_T], None] | None = ...,
error_callback: Callable[[BaseException], None] | None = ...,
) -> MapResult[_T]: ...
def imap(self, func: Callable[[_S], _T], iterable: Iterable[_S], chunksize: Optional[int] = ...) -> IMapIterator[_T]: ...
def imap(self, func: Callable[[_S], _T], iterable: Iterable[_S], chunksize: int | None = ...) -> IMapIterator[_T]: ...
def imap_unordered(
self, func: Callable[[_S], _T], iterable: Iterable[_S], chunksize: Optional[int] = ...
self, func: Callable[[_S], _T], iterable: Iterable[_S], chunksize: int | None = ...
) -> IMapIterator[_T]: ...
def starmap(self, func: Callable[..., _T], iterable: Iterable[Iterable[Any]], chunksize: Optional[int] = ...) -> List[_T]: ...
def starmap(self, func: Callable[..., _T], iterable: Iterable[Iterable[Any]], chunksize: int | None = ...) -> List[_T]: ...
def starmap_async(
self,
func: Callable[..., _T],
iterable: Iterable[Iterable[Any]],
chunksize: Optional[int] = ...,
callback: Optional[Callable[[_T], None]] = ...,
error_callback: Optional[Callable[[BaseException], None]] = ...,
chunksize: int | None = ...,
callback: Callable[[_T], None] | None = ...,
error_callback: Callable[[BaseException], None] | None = ...,
) -> AsyncResult[List[_T]]: ...
def close(self) -> None: ...
def terminate(self) -> None: ...
@@ -82,7 +82,7 @@ class Pool(ContextManager[Pool]):
class ThreadPool(Pool, ContextManager[ThreadPool]):
def __init__(
self, processes: Optional[int] = ..., initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ...
self, processes: int | None = ..., initializer: Callable[..., Any] | None = ..., initargs: Iterable[Any] = ...
) -> None: ...
# undocumented

View File

@@ -1,5 +1,5 @@
import sys
from typing import Any, Callable, List, Mapping, Optional, Tuple
from typing import Any, Callable, List, Mapping, Tuple
class BaseProcess:
name: str
@@ -8,12 +8,12 @@ class BaseProcess:
def __init__(
self,
group: None = ...,
target: Optional[Callable[..., Any]] = ...,
name: Optional[str] = ...,
target: Callable[..., Any] | None = ...,
name: str | None = ...,
args: Tuple[Any, ...] = ...,
kwargs: Mapping[str, Any] = ...,
*,
daemon: Optional[bool] = ...,
daemon: bool | None = ...,
) -> None: ...
def run(self) -> None: ...
def start(self) -> None: ...
@@ -21,14 +21,14 @@ class BaseProcess:
if sys.version_info >= (3, 7):
def kill(self) -> None: ...
def close(self) -> None: ...
def join(self, timeout: Optional[float] = ...) -> None: ...
def join(self, timeout: float | None = ...) -> None: ...
def is_alive(self) -> bool: ...
@property
def exitcode(self) -> Optional[int]: ...
def exitcode(self) -> int | None: ...
@property
def ident(self) -> Optional[int]: ...
def ident(self) -> int | None: ...
@property
def pid(self) -> Optional[int]: ...
def pid(self) -> int | None: ...
@property
def sentinel(self) -> int: ...
@@ -36,4 +36,4 @@ def current_process() -> BaseProcess: ...
def active_children() -> List[BaseProcess]: ...
if sys.version_info >= (3, 8):
def parent_process() -> Optional[BaseProcess]: ...
def parent_process() -> BaseProcess | None: ...

View File

@@ -1,6 +1,6 @@
import queue
import sys
from typing import Any, Generic, Optional, TypeVar
from typing import Any, Generic, TypeVar
if sys.version_info >= (3, 9):
from types import GenericAlias
@@ -11,8 +11,8 @@ class Queue(queue.Queue[_T]):
# FIXME: `ctx` is a circular dependency and it's not actually optional.
# It's marked as such to be able to use the generic Queue in __init__.pyi.
def __init__(self, maxsize: int = ..., *, ctx: Any = ...) -> None: ...
def get(self, block: bool = ..., timeout: Optional[float] = ...) -> _T: ...
def put(self, obj: _T, block: bool = ..., timeout: Optional[float] = ...) -> None: ...
def get(self, block: bool = ..., timeout: float | None = ...) -> _T: ...
def put(self, obj: _T, block: bool = ..., timeout: float | None = ...) -> None: ...
def qsize(self) -> int: ...
def empty(self) -> bool: ...
def full(self) -> bool: ...

View File

@@ -1,5 +1,5 @@
import sys
from typing import Any, Generic, Iterable, Optional, Tuple, TypeVar
from typing import Any, Generic, Iterable, Tuple, TypeVar
if sys.version_info >= (3, 9):
from types import GenericAlias
@@ -9,7 +9,7 @@ _SLT = TypeVar("_SLT", int, float, bool, str, bytes, None)
if sys.version_info >= (3, 8):
class SharedMemory:
def __init__(self, name: Optional[str] = ..., create: bool = ..., size: int = ...) -> None: ...
def __init__(self, name: str | None = ..., create: bool = ..., size: int = ...) -> None: ...
@property
def buf(self) -> memoryview: ...
@property
@@ -20,7 +20,7 @@ if sys.version_info >= (3, 8):
def unlink(self) -> None: ...
class ShareableList(Generic[_SLT]):
shm: SharedMemory
def __init__(self, sequence: Optional[Iterable[_SLT]] = ..., *, name: Optional[str] = ...) -> None: ...
def __init__(self, sequence: Iterable[_SLT] | None = ..., *, name: str | None = ...) -> None: ...
def __getitem__(self, position: int) -> _SLT: ...
def __setitem__(self, position: int, value: _SLT) -> None: ...
def __reduce__(self: _S) -> Tuple[_S, Tuple[_SLT, ...]]: ...

View File

@@ -3,7 +3,7 @@ from collections.abc import Callable, Iterable, Sequence
from ctypes import _CData, _SimpleCData, c_char
from multiprocessing.context import BaseContext
from multiprocessing.synchronize import _LockLike
from typing import Any, Generic, Optional, Protocol, Type, TypeVar, Union, overload
from typing import Any, Generic, Protocol, Type, TypeVar, overload
from typing_extensions import Literal
_T = TypeVar("_T")
@@ -14,72 +14,68 @@ def RawValue(typecode_or_type: Type[_CT], *args: Any) -> _CT: ...
@overload
def RawValue(typecode_or_type: str, *args: Any) -> Any: ...
@overload
def RawArray(typecode_or_type: Type[_CT], size_or_initializer: Union[int, Sequence[Any]]) -> ctypes.Array[_CT]: ...
def RawArray(typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any]) -> ctypes.Array[_CT]: ...
@overload
def RawArray(typecode_or_type: str, size_or_initializer: Union[int, Sequence[Any]]) -> Any: ...
def RawArray(typecode_or_type: str, size_or_initializer: int | Sequence[Any]) -> Any: ...
@overload
def Value(typecode_or_type: Type[_CT], *args: Any, lock: Literal[False], ctx: Optional[BaseContext] = ...) -> _CT: ...
def Value(typecode_or_type: Type[_CT], *args: Any, lock: Literal[False], ctx: BaseContext | None = ...) -> _CT: ...
@overload
def Value(
typecode_or_type: Type[_CT], *args: Any, lock: Union[Literal[True], _LockLike], ctx: Optional[BaseContext] = ...
typecode_or_type: Type[_CT], *args: Any, lock: Literal[True] | _LockLike, ctx: BaseContext | None = ...
) -> SynchronizedBase[_CT]: ...
@overload
def Value(
typecode_or_type: str, *args: Any, lock: Union[Literal[True], _LockLike], ctx: Optional[BaseContext] = ...
typecode_or_type: str, *args: Any, lock: Literal[True] | _LockLike, ctx: BaseContext | None = ...
) -> SynchronizedBase[Any]: ...
@overload
def Value(
typecode_or_type: Union[str, Type[_CData]], *args: Any, lock: Union[bool, _LockLike] = ..., ctx: Optional[BaseContext] = ...
typecode_or_type: str | Type[_CData], *args: Any, lock: bool | _LockLike = ..., ctx: BaseContext | None = ...
) -> Any: ...
@overload
def Array(
typecode_or_type: Type[_CT],
size_or_initializer: Union[int, Sequence[Any]],
*,
lock: Literal[False],
ctx: Optional[BaseContext] = ...,
typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False], ctx: BaseContext | None = ...
) -> _CT: ...
@overload
def Array(
typecode_or_type: Type[_CT],
size_or_initializer: Union[int, Sequence[Any]],
size_or_initializer: int | Sequence[Any],
*,
lock: Union[Literal[True], _LockLike],
ctx: Optional[BaseContext] = ...,
lock: Literal[True] | _LockLike,
ctx: BaseContext | None = ...,
) -> SynchronizedArray[_CT]: ...
@overload
def Array(
typecode_or_type: str,
size_or_initializer: Union[int, Sequence[Any]],
size_or_initializer: int | Sequence[Any],
*,
lock: Union[Literal[True], _LockLike],
ctx: Optional[BaseContext] = ...,
lock: Literal[True] | _LockLike,
ctx: BaseContext | None = ...,
) -> SynchronizedArray[Any]: ...
@overload
def Array(
typecode_or_type: Union[str, Type[_CData]],
size_or_initializer: Union[int, Sequence[Any]],
typecode_or_type: str | Type[_CData],
size_or_initializer: int | Sequence[Any],
*,
lock: Union[bool, _LockLike] = ...,
ctx: Optional[BaseContext] = ...,
lock: bool | _LockLike = ...,
ctx: BaseContext | None = ...,
) -> Any: ...
def copy(obj: _CT) -> _CT: ...
@overload
def synchronized(obj: _SimpleCData[_T], lock: Optional[_LockLike] = ..., ctx: Optional[Any] = ...) -> Synchronized[_T]: ...
def synchronized(obj: _SimpleCData[_T], lock: _LockLike | None = ..., ctx: Any | None = ...) -> Synchronized[_T]: ...
@overload
def synchronized(obj: ctypes.Array[c_char], lock: Optional[_LockLike] = ..., ctx: Optional[Any] = ...) -> SynchronizedString: ...
def synchronized(obj: ctypes.Array[c_char], lock: _LockLike | None = ..., ctx: Any | None = ...) -> SynchronizedString: ...
@overload
def synchronized(obj: ctypes.Array[_CT], lock: Optional[_LockLike] = ..., ctx: Optional[Any] = ...) -> SynchronizedArray[_CT]: ...
def synchronized(obj: ctypes.Array[_CT], lock: _LockLike | None = ..., ctx: Any | None = ...) -> SynchronizedArray[_CT]: ...
@overload
def synchronized(obj: _CT, lock: Optional[_LockLike] = ..., ctx: Optional[Any] = ...) -> SynchronizedBase[_CT]: ...
def synchronized(obj: _CT, lock: _LockLike | None = ..., ctx: Any | None = ...) -> SynchronizedBase[_CT]: ...
class _AcquireFunc(Protocol):
def __call__(self, block: bool = ..., timeout: Optional[float] = ...) -> bool: ...
def __call__(self, block: bool = ..., timeout: float | None = ...) -> bool: ...
class SynchronizedBase(Generic[_CT]):
acquire: _AcquireFunc = ...
release: Callable[[], None] = ...
def __init__(self, obj: Any, lock: Optional[_LockLike] = ..., ctx: Optional[Any] = ...) -> None: ...
def __init__(self, obj: Any, lock: _LockLike | None = ..., ctx: Any | None = ...) -> None: ...
def __reduce__(self) -> tuple[Callable[..., Any], tuple[Any, _LockLike]]: ...
def get_obj(self) -> _CT: ...
def get_lock(self) -> _LockLike: ...

View File

@@ -1,5 +1,5 @@
from types import ModuleType
from typing import Any, Dict, List, Mapping, Optional, Sequence
from typing import Any, Dict, List, Mapping, Sequence
WINEXE: bool
WINSERVICE: bool
@@ -9,7 +9,7 @@ def get_executable() -> str: ...
def is_forking(argv: Sequence[str]) -> bool: ...
def freeze_support() -> None: ...
def get_command_line(**kwds: Any) -> List[str]: ...
def spawn_main(pipe_handle: int, parent_pid: Optional[int] = ..., tracker_fd: Optional[int] = ...) -> None: ...
def spawn_main(pipe_handle: int, parent_pid: int | None = ..., tracker_fd: int | None = ...) -> None: ...
# undocumented
def _main(fd: int) -> Any: ...

View File

@@ -1,36 +1,36 @@
import sys
import threading
from multiprocessing.context import BaseContext
from typing import Any, Callable, ContextManager, Optional, Union
from typing import Any, Callable, ContextManager, Union
_LockLike = Union[Lock, RLock]
class Barrier(threading.Barrier):
def __init__(
self, parties: int, action: Optional[Callable[..., Any]] = ..., timeout: Optional[float] = ..., *ctx: BaseContext
self, parties: int, action: Callable[..., Any] | None = ..., timeout: float | None = ..., *ctx: BaseContext
) -> None: ...
class BoundedSemaphore(Semaphore):
def __init__(self, value: int = ..., *, ctx: BaseContext) -> None: ...
class Condition(ContextManager[bool]):
def __init__(self, lock: Optional[_LockLike] = ..., *, ctx: BaseContext) -> None: ...
def __init__(self, lock: _LockLike | None = ..., *, ctx: BaseContext) -> None: ...
if sys.version_info >= (3, 7):
def notify(self, n: int = ...) -> None: ...
else:
def notify(self) -> None: ...
def notify_all(self) -> None: ...
def wait(self, timeout: Optional[float] = ...) -> bool: ...
def wait_for(self, predicate: Callable[[], bool], timeout: Optional[float] = ...) -> bool: ...
def acquire(self, block: bool = ..., timeout: Optional[float] = ...) -> bool: ...
def wait(self, timeout: float | None = ...) -> bool: ...
def wait_for(self, predicate: Callable[[], bool], timeout: float | None = ...) -> bool: ...
def acquire(self, block: bool = ..., timeout: float | None = ...) -> bool: ...
def release(self) -> None: ...
class Event(ContextManager[bool]):
def __init__(self, lock: Optional[_LockLike] = ..., *, ctx: BaseContext) -> None: ...
def __init__(self, lock: _LockLike | None = ..., *, ctx: BaseContext) -> None: ...
def is_set(self) -> bool: ...
def set(self) -> None: ...
def clear(self) -> None: ...
def wait(self, timeout: Optional[float] = ...) -> bool: ...
def wait(self, timeout: float | None = ...) -> bool: ...
class Lock(SemLock):
def __init__(self, *, ctx: BaseContext) -> None: ...
@@ -43,5 +43,5 @@ class Semaphore(SemLock):
# Not part of public API
class SemLock(ContextManager[bool]):
def acquire(self, block: bool = ..., timeout: Optional[float] = ...) -> bool: ...
def acquire(self, block: bool = ..., timeout: float | None = ...) -> bool: ...
def release(self) -> None: ...