mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-09 13:02:22 +08:00
apply black and isort (#4287)
* apply black and isort * move some type ignores
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import sys
|
||||
from typing import Any, Callable, Iterable, Optional, List, Union, Sequence, Tuple, Type, overload
|
||||
from typing_extensions import Literal
|
||||
from ctypes import _CData
|
||||
from logging import Logger
|
||||
from multiprocessing import connection, pool, sharedctypes, spawn, synchronize
|
||||
@@ -16,9 +14,11 @@ from multiprocessing.context import (
|
||||
)
|
||||
from multiprocessing.managers import SyncManager
|
||||
from multiprocessing.process import active_children as active_children, current_process as current_process
|
||||
from multiprocessing.queues import Queue as Queue, SimpleQueue as SimpleQueue, JoinableQueue as JoinableQueue
|
||||
from multiprocessing.spawn import freeze_support as freeze_support
|
||||
from multiprocessing.spawn import set_executable as set_executable
|
||||
from multiprocessing.queues import JoinableQueue as JoinableQueue, Queue as Queue, SimpleQueue as SimpleQueue
|
||||
from multiprocessing.spawn import freeze_support as freeze_support, set_executable as set_executable
|
||||
from typing import Any, Callable, Iterable, List, Optional, Sequence, Tuple, Type, Union, overload
|
||||
|
||||
from typing_extensions import Literal
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from multiprocessing.process import parent_process as parent_process
|
||||
@@ -32,38 +32,27 @@ if sys.platform != "win32":
|
||||
|
||||
# Sychronization primitives
|
||||
_LockLike = Union[synchronize.Lock, synchronize.RLock]
|
||||
def Barrier(parties: int,
|
||||
action: Optional[Callable[..., Any]] = ...,
|
||||
timeout: Optional[float] = ...) -> synchronize.Barrier: ...
|
||||
|
||||
def Barrier(parties: int, action: Optional[Callable[..., Any]] = ..., timeout: Optional[float] = ...) -> synchronize.Barrier: ...
|
||||
def BoundedSemaphore(value: int = ...) -> synchronize.BoundedSemaphore: ...
|
||||
def Condition(lock: Optional[_LockLike] = ...) -> synchronize.Condition: ...
|
||||
def Event(lock: Optional[_LockLike] = ...) -> synchronize.Event: ...
|
||||
def Lock() -> synchronize.Lock: ...
|
||||
def RLock() -> synchronize.RLock: ...
|
||||
def Semaphore(value: int = ...) -> synchronize.Semaphore: ...
|
||||
|
||||
def Pipe(duplex: bool = ...) -> Tuple[connection.Connection, connection.Connection]: ...
|
||||
|
||||
def Pool(processes: Optional[int] = ...,
|
||||
initializer: Optional[Callable[..., Any]] = ...,
|
||||
initargs: Iterable[Any] = ...,
|
||||
maxtasksperchild: Optional[int] = ...) -> pool.Pool: ...
|
||||
def Pool(
|
||||
processes: Optional[int] = ...,
|
||||
initializer: Optional[Callable[..., Any]] = ...,
|
||||
initargs: Iterable[Any] = ...,
|
||||
maxtasksperchild: Optional[int] = ...,
|
||||
) -> pool.Pool: ...
|
||||
|
||||
# Functions Array and Value are copied from context.pyi.
|
||||
# See https://github.com/python/typeshed/blob/ac234f25927634e06d9c96df98d72d54dd80dfc4/stdlib/2and3/turtle.pyi#L284-L291
|
||||
# for rationale
|
||||
def Array(
|
||||
typecode_or_type: Any,
|
||||
size_or_initializer: Union[int, Sequence[Any]],
|
||||
*,
|
||||
lock: bool = ...
|
||||
) -> sharedctypes._Array: ...
|
||||
|
||||
def Value(
|
||||
typecode_or_type: Any,
|
||||
*args: Any,
|
||||
lock: bool = ...
|
||||
) -> sharedctypes._Value: ...
|
||||
def Array(typecode_or_type: Any, size_or_initializer: Union[int, Sequence[Any]], *, lock: bool = ...) -> sharedctypes._Array: ...
|
||||
def Value(typecode_or_type: Any, *args: Any, lock: bool = ...) -> sharedctypes._Value: ...
|
||||
|
||||
# ----- multiprocessing function stubs -----
|
||||
def allow_connection_pickling() -> None: ...
|
||||
@@ -76,7 +65,6 @@ 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: ...
|
||||
|
||||
|
||||
if sys.platform != "win32":
|
||||
@overload
|
||||
def get_context(method: None = ...) -> DefaultContext: ...
|
||||
@@ -88,6 +76,7 @@ if sys.platform != "win32":
|
||||
def get_context(method: Literal["forkserver"]) -> ForkServerContext: ...
|
||||
@overload
|
||||
def get_context(method: str) -> BaseContext: ...
|
||||
|
||||
else:
|
||||
@overload
|
||||
def get_context(method: None = ...) -> DefaultContext: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from typing import Any, Iterable, List, Optional, Tuple, Type, Union
|
||||
import socket
|
||||
import sys
|
||||
import types
|
||||
from typing import Any, Iterable, List, Optional, Tuple, Type, Union
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import SupportsIndex
|
||||
@@ -14,7 +14,6 @@ class _ConnectionBase:
|
||||
def __init__(self, handle: SupportsIndex, readable: bool = ..., writable: bool = ...) -> None: ...
|
||||
else:
|
||||
def __init__(self, handle: int, readable: bool = ..., writable: bool = ...) -> None: ...
|
||||
|
||||
@property
|
||||
def closed(self) -> bool: ... # undocumented
|
||||
@property
|
||||
@@ -23,17 +22,16 @@ 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: Optional[int] = ...) -> None: ...
|
||||
def send(self, obj: Any) -> None: ...
|
||||
def recv_bytes(self, maxlength: Optional[int] = ...) -> bytes: ...
|
||||
def recv_bytes_into(self, buf: Any, offset: int = ...) -> int: ...
|
||||
def recv(self) -> Any: ...
|
||||
def poll(self, timeout: Optional[float] = ...) -> bool: ...
|
||||
def __enter__(self) -> _ConnectionBase: ...
|
||||
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], exc_tb: Optional[types.TracebackType]) -> None: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], exc_tb: Optional[types.TracebackType]
|
||||
) -> None: ...
|
||||
|
||||
class Connection(_ConnectionBase): ...
|
||||
|
||||
@@ -41,7 +39,9 @@ if sys.platform == "win32":
|
||||
class PipeConnection(_ConnectionBase): ...
|
||||
|
||||
class Listener:
|
||||
def __init__(self, address: Optional[_Address] = ..., family: Optional[str] = ..., backlog: int = ..., authkey: Optional[bytes] = ...) -> None: ...
|
||||
def __init__(
|
||||
self, address: Optional[_Address] = ..., family: Optional[str] = ..., backlog: int = ..., authkey: Optional[bytes] = ...
|
||||
) -> None: ...
|
||||
def accept(self) -> Connection: ...
|
||||
def close(self) -> None: ...
|
||||
@property
|
||||
@@ -49,10 +49,14 @@ class Listener:
|
||||
@property
|
||||
def last_accepted(self) -> Optional[_Address]: ...
|
||||
def __enter__(self) -> Listener: ...
|
||||
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], exc_tb: Optional[types.TracebackType]) -> None: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], exc_tb: Optional[types.TracebackType]
|
||||
) -> 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 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: ...
|
||||
def Pipe(duplex: bool = ...) -> Tuple[Connection, Connection]: ...
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
from logging import Logger
|
||||
import multiprocessing
|
||||
from multiprocessing import sharedctypes
|
||||
from multiprocessing import synchronize
|
||||
from multiprocessing import queues
|
||||
from multiprocessing.process import BaseProcess
|
||||
import sys
|
||||
from typing import Any, Callable, Iterable, Optional, List, Sequence, Type, Union, overload
|
||||
from logging import Logger
|
||||
from multiprocessing import queues, sharedctypes, synchronize
|
||||
from multiprocessing.process import BaseProcess
|
||||
from typing import Any, Callable, Iterable, List, Optional, Sequence, Type, Union, overload
|
||||
|
||||
from typing_extensions import Literal
|
||||
|
||||
_LockLike = Union[synchronize.Lock, synchronize.RLock]
|
||||
|
||||
class ProcessError(Exception): ...
|
||||
|
||||
class BufferTooShort(ProcessError): ...
|
||||
|
||||
class TimeoutError(ProcessError): ...
|
||||
|
||||
class AuthenticationError(ProcessError): ...
|
||||
|
||||
class BaseContext(object):
|
||||
@@ -27,7 +23,6 @@ class BaseContext(object):
|
||||
|
||||
# N.B. The methods below are applied at runtime to generate
|
||||
# multiprocessing.*, so the signatures should be identical (modulo self).
|
||||
|
||||
@staticmethod
|
||||
def current_process() -> BaseProcess: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
@@ -40,20 +35,15 @@ class BaseContext(object):
|
||||
def Manager(self) -> Any: ...
|
||||
# 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] = ...) -> synchronize.Barrier: ...
|
||||
def BoundedSemaphore(self,
|
||||
value: int = ...) -> synchronize.BoundedSemaphore: ...
|
||||
def Condition(self,
|
||||
lock: Optional[_LockLike] = ...) -> synchronize.Condition: ...
|
||||
def Barrier(
|
||||
self, parties: int, action: Optional[Callable[..., Any]] = ..., timeout: Optional[float] = ...
|
||||
) -> synchronize.Barrier: ...
|
||||
def BoundedSemaphore(self, value: int = ...) -> synchronize.BoundedSemaphore: ...
|
||||
def Condition(self, lock: Optional[_LockLike] = ...) -> synchronize.Condition: ...
|
||||
def Event(self, lock: Optional[_LockLike] = ...) -> synchronize.Event: ...
|
||||
def Lock(self) -> synchronize.Lock: ...
|
||||
def RLock(self) -> synchronize.RLock: ...
|
||||
def Semaphore(self, value: int = ...) -> synchronize.Semaphore: ...
|
||||
|
||||
def Queue(self, maxsize: int = ...) -> queues.Queue[Any]: ...
|
||||
def JoinableQueue(self, maxsize: int = ...) -> queues.JoinableQueue[Any]: ...
|
||||
def SimpleQueue(self) -> queues.SimpleQueue[Any]: ...
|
||||
@@ -62,7 +52,7 @@ class BaseContext(object):
|
||||
processes: Optional[int] = ...,
|
||||
initializer: Optional[Callable[..., Any]] = ...,
|
||||
initargs: Iterable[Any] = ...,
|
||||
maxtasksperchild: Optional[int] = ...
|
||||
maxtasksperchild: Optional[int] = ...,
|
||||
) -> multiprocessing.pool.Pool: ...
|
||||
# TODO: typecode_or_type param is a ctype with a base class of _SimpleCData or array.typecode Need to figure out
|
||||
# how to handle the ctype
|
||||
@@ -74,20 +64,11 @@ class BaseContext(object):
|
||||
def RawArray(self, typecode_or_type: Any, size_or_initializer: Union[int, Sequence[Any]]) -> Any: ...
|
||||
# TODO: typecode_or_type param is a ctype with a base class of _SimpleCData or array.typecode Need to figure out
|
||||
# how to handle the ctype
|
||||
def Value(
|
||||
self,
|
||||
typecode_or_type: Any,
|
||||
*args: Any,
|
||||
lock: bool = ...
|
||||
) -> sharedctypes._Value: ...
|
||||
def Value(self, typecode_or_type: Any, *args: Any, lock: bool = ...) -> sharedctypes._Value: ...
|
||||
# TODO: typecode_or_type param is a ctype with a base class of _SimpleCData or array.typecode Need to figure out
|
||||
# how to handle the ctype
|
||||
def Array(
|
||||
self,
|
||||
typecode_or_type: Any,
|
||||
size_or_initializer: Union[int, Sequence[Any]],
|
||||
*,
|
||||
lock: bool = ...
|
||||
self, typecode_or_type: Any, size_or_initializer: Union[int, Sequence[Any]], *, lock: bool = ...
|
||||
) -> sharedctypes._Array: ...
|
||||
def freeze_support(self) -> None: ...
|
||||
def get_logger(self) -> Logger: ...
|
||||
@@ -95,7 +76,6 @@ class BaseContext(object):
|
||||
def allow_connection_pickling(self) -> None: ...
|
||||
def set_executable(self, executable: str) -> None: ...
|
||||
def set_forkserver_preload(self, module_names: List[str]) -> None: ...
|
||||
|
||||
if sys.platform != "win32":
|
||||
@overload
|
||||
def get_context(self, method: None = ...) -> DefaultContext: ...
|
||||
@@ -114,7 +94,6 @@ class BaseContext(object):
|
||||
def get_context(self, method: Literal["spawn"]) -> SpawnContext: ...
|
||||
@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: ...
|
||||
@property
|
||||
@@ -130,45 +109,39 @@ class Process(BaseProcess):
|
||||
|
||||
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 get_start_method(self, allow_none: bool = ...) -> str: ...
|
||||
def get_all_start_methods(self) -> List[str]: ...
|
||||
|
||||
if sys.platform != 'win32':
|
||||
if sys.platform != "win32":
|
||||
class ForkProcess(BaseProcess):
|
||||
_start_method: str
|
||||
@staticmethod
|
||||
def _Popen(process_obj: BaseProcess) -> Any: ...
|
||||
|
||||
class SpawnProcess(BaseProcess):
|
||||
_start_method: str
|
||||
@staticmethod
|
||||
def _Popen(process_obj: BaseProcess) -> SpawnProcess: ...
|
||||
|
||||
class ForkServerProcess(BaseProcess):
|
||||
_start_method: str
|
||||
@staticmethod
|
||||
def _Popen(process_obj: BaseProcess) -> Any: ...
|
||||
|
||||
class ForkContext(BaseContext):
|
||||
_name: str
|
||||
Process: Type[ForkProcess]
|
||||
|
||||
class SpawnContext(BaseContext):
|
||||
_name: str
|
||||
Process: Type[SpawnProcess]
|
||||
|
||||
class ForkServerContext(BaseContext):
|
||||
_name: str
|
||||
Process: Type[ForkServerProcess]
|
||||
|
||||
else:
|
||||
class SpawnProcess(BaseProcess):
|
||||
_start_method: str
|
||||
@staticmethod
|
||||
def _Popen(process_obj: BaseProcess) -> Any: ...
|
||||
|
||||
class SpawnContext(BaseContext):
|
||||
_name: str
|
||||
Process: Type[SpawnProcess]
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
from typing import Any, Optional, List
|
||||
|
||||
import array
|
||||
import threading
|
||||
import weakref
|
||||
|
||||
from queue import Queue as Queue
|
||||
from typing import Any, List, Optional
|
||||
|
||||
JoinableQueue = Queue
|
||||
Barrier = threading.Barrier
|
||||
@@ -36,7 +34,6 @@ class Value:
|
||||
value: Any
|
||||
def __init__(self, typecode, value, lock=...) -> None: ...
|
||||
|
||||
|
||||
def Array(typecode, sequence, lock=...) -> array.array[Any]: ...
|
||||
def Manager() -> Any: ...
|
||||
def Pool(processes=..., initializer=..., initargs=...) -> Any: ...
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
from typing import Any, List, Optional, Tuple, TypeVar
|
||||
|
||||
from queue import Queue
|
||||
from typing import Any, List, Optional, Tuple, TypeVar
|
||||
|
||||
families: List[None]
|
||||
|
||||
_TConnection = TypeVar('_TConnection', bound=Connection)
|
||||
_TListener = TypeVar('_TListener', bound=Listener)
|
||||
_TConnection = TypeVar("_TConnection", bound=Connection)
|
||||
_TListener = TypeVar("_TListener", bound=Listener)
|
||||
|
||||
class Connection(object):
|
||||
_in: Any
|
||||
@@ -30,6 +29,5 @@ class Listener(object):
|
||||
def accept(self) -> Connection: ...
|
||||
def close(self) -> None: ...
|
||||
|
||||
|
||||
def Client(address) -> Connection: ...
|
||||
def Pipe(duplex: bool = ...) -> Tuple[Connection, Connection]: ...
|
||||
|
||||
@@ -6,17 +6,30 @@ import queue
|
||||
import sys
|
||||
import threading
|
||||
from typing import (
|
||||
Any, Callable, ContextManager, Dict, Iterable, Generic, List, Mapping, Optional,
|
||||
Sequence, Tuple, TypeVar, Union, AnyStr,
|
||||
Any,
|
||||
AnyStr,
|
||||
Callable,
|
||||
ContextManager,
|
||||
Dict,
|
||||
Generic,
|
||||
Iterable,
|
||||
List,
|
||||
Mapping,
|
||||
Optional,
|
||||
Sequence,
|
||||
Tuple,
|
||||
TypeVar,
|
||||
Union,
|
||||
)
|
||||
|
||||
from .context import BaseContext
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from .shared_memory import ShareableList, SharedMemory, _SLT
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_KT = TypeVar('_KT')
|
||||
_VT = TypeVar('_VT')
|
||||
_T = TypeVar("_T")
|
||||
_KT = TypeVar("_KT")
|
||||
_VT = TypeVar("_VT")
|
||||
|
||||
class Namespace:
|
||||
def __init__(self, **kwds: Any) -> None: ...
|
||||
@@ -29,28 +42,43 @@ 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: ...
|
||||
def __init__(
|
||||
self, typeid: Optional[Union[bytes, str]], address: Tuple[Union[str, bytes], int], id: Optional[Union[str, bytes, int]]
|
||||
) -> 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[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: ...
|
||||
|
||||
class BaseProxy(object):
|
||||
_address_to_local: Dict[Any, Any]
|
||||
_mutex: Any
|
||||
if sys.version_info >= (3, 6):
|
||||
def __init__(self, token: Any, serializer: str, manager: Any = ...,
|
||||
authkey: Optional[AnyStr] = ..., exposed: Any = ...,
|
||||
incref: bool = ..., manager_owned: bool = ...) -> None: ...
|
||||
def __init__(
|
||||
self,
|
||||
token: Any,
|
||||
serializer: str,
|
||||
manager: Any = ...,
|
||||
authkey: Optional[AnyStr] = ...,
|
||||
exposed: Any = ...,
|
||||
incref: bool = ...,
|
||||
manager_owned: bool = ...,
|
||||
) -> None: ...
|
||||
else:
|
||||
def __init__(self, token: Any, serializer: str, manager: Any = ...,
|
||||
authkey: Optional[AnyStr] = ..., exposed: Any = ...,
|
||||
incref: bool = ...) -> None: ...
|
||||
def __init__(
|
||||
self,
|
||||
token: Any,
|
||||
serializer: str,
|
||||
manager: Any = ...,
|
||||
authkey: Optional[AnyStr] = ...,
|
||||
exposed: Any = ...,
|
||||
incref: bool = ...,
|
||||
) -> None: ...
|
||||
def __deepcopy__(self, memo: Optional[Any]) -> Any: ...
|
||||
def _callmethod(self, methodname: str, args: Tuple[Any, ...] = ...,
|
||||
kwds: Dict[Any, Any] = ...) -> None: ...
|
||||
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]]]: ...
|
||||
|
||||
@@ -80,11 +108,15 @@ class BaseManager(ContextManager[BaseManager]):
|
||||
@property
|
||||
def address(self) -> Any: ...
|
||||
@classmethod
|
||||
def register(cls, typeid: str, callable: Optional[Callable[..., Any]] = ...,
|
||||
proxytype: Any = ...,
|
||||
exposed: Optional[Sequence[str]] = ...,
|
||||
method_to_typeid: Optional[Mapping[str, str]] = ...,
|
||||
create_method: bool = ...) -> None: ...
|
||||
def register(
|
||||
cls,
|
||||
typeid: str,
|
||||
callable: Optional[Callable[..., Any]] = ...,
|
||||
proxytype: Any = ...,
|
||||
exposed: Optional[Sequence[str]] = ...,
|
||||
method_to_typeid: Optional[Mapping[str, str]] = ...,
|
||||
create_method: bool = ...,
|
||||
) -> None: ...
|
||||
|
||||
class SyncManager(BaseManager, ContextManager[SyncManager]):
|
||||
def BoundedSemaphore(self, value: Any = ...) -> threading.BoundedSemaphore: ...
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from typing import Any, Callable, ContextManager, Iterable, Mapping, Optional, List, TypeVar, Generic, Iterator
|
||||
from typing import Any, Callable, ContextManager, Generic, Iterable, Iterator, List, Mapping, Optional, TypeVar
|
||||
|
||||
_PT = TypeVar('_PT', bound=Pool)
|
||||
_S = TypeVar('_S')
|
||||
_T = TypeVar('_T')
|
||||
_PT = TypeVar("_PT", bound=Pool)
|
||||
_S = TypeVar("_S")
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class ApplyResult(Generic[_T]):
|
||||
def get(self, timeout: Optional[float] = ...) -> _T: ...
|
||||
@@ -23,59 +23,58 @@ class IMapIterator(Iterator[_T]):
|
||||
class IMapUnorderedIterator(IMapIterator[_T]): ...
|
||||
|
||||
class Pool(ContextManager[Pool]):
|
||||
def __init__(self, processes: Optional[int] = ...,
|
||||
initializer: Optional[Callable[..., None]] = ...,
|
||||
initargs: Iterable[Any] = ...,
|
||||
maxtasksperchild: Optional[int] = ...,
|
||||
context: Optional[Any] = ...) -> None: ...
|
||||
def apply(self,
|
||||
func: Callable[..., _T],
|
||||
args: Iterable[Any] = ...,
|
||||
kwds: Mapping[str, Any] = ...) -> _T: ...
|
||||
def apply_async(self,
|
||||
func: Callable[..., _T],
|
||||
args: Iterable[Any] = ...,
|
||||
kwds: Mapping[str, Any] = ...,
|
||||
callback: Optional[Callable[[_T], None]] = ...,
|
||||
error_callback: Optional[Callable[[BaseException], None]] = ...) -> AsyncResult[_T]: ...
|
||||
def map(self,
|
||||
func: Callable[[_S], _T],
|
||||
iterable: Iterable[_S] = ...,
|
||||
chunksize: Optional[int] = ...) -> 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]] = ...) -> MapResult[_T]: ...
|
||||
def imap(self,
|
||||
func: Callable[[_S], _T],
|
||||
iterable: Iterable[_S] = ...,
|
||||
chunksize: Optional[int] = ...) -> IMapIterator[_T]: ...
|
||||
def imap_unordered(self,
|
||||
func: Callable[[_S], _T],
|
||||
iterable: Iterable[_S] = ...,
|
||||
chunksize: Optional[int] = ...) -> IMapIterator[_T]: ...
|
||||
def starmap(self,
|
||||
func: Callable[..., _T],
|
||||
iterable: Iterable[Iterable[Any]] = ...,
|
||||
chunksize: Optional[int] = ...) -> 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]] = ...) -> AsyncResult[List[_T]]: ...
|
||||
def __init__(
|
||||
self,
|
||||
processes: Optional[int] = ...,
|
||||
initializer: Optional[Callable[..., None]] = ...,
|
||||
initargs: Iterable[Any] = ...,
|
||||
maxtasksperchild: Optional[int] = ...,
|
||||
context: Optional[Any] = ...,
|
||||
) -> None: ...
|
||||
def apply(self, func: Callable[..., _T], args: Iterable[Any] = ..., kwds: Mapping[str, Any] = ...) -> _T: ...
|
||||
def apply_async(
|
||||
self,
|
||||
func: Callable[..., _T],
|
||||
args: Iterable[Any] = ...,
|
||||
kwds: Mapping[str, Any] = ...,
|
||||
callback: Optional[Callable[[_T], None]] = ...,
|
||||
error_callback: Optional[Callable[[BaseException], None]] = ...,
|
||||
) -> AsyncResult[_T]: ...
|
||||
def map(self, func: Callable[[_S], _T], iterable: Iterable[_S] = ..., chunksize: Optional[int] = ...) -> 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]] = ...,
|
||||
) -> MapResult[_T]: ...
|
||||
def imap(
|
||||
self, func: Callable[[_S], _T], iterable: Iterable[_S] = ..., chunksize: Optional[int] = ...
|
||||
) -> IMapIterator[_T]: ...
|
||||
def imap_unordered(
|
||||
self, func: Callable[[_S], _T], iterable: Iterable[_S] = ..., chunksize: Optional[int] = ...
|
||||
) -> IMapIterator[_T]: ...
|
||||
def starmap(
|
||||
self, func: Callable[..., _T], iterable: Iterable[Iterable[Any]] = ..., chunksize: Optional[int] = ...
|
||||
) -> 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]] = ...,
|
||||
) -> AsyncResult[List[_T]]: ...
|
||||
def close(self) -> None: ...
|
||||
def terminate(self) -> None: ...
|
||||
def join(self) -> None: ...
|
||||
def __enter__(self: _PT) -> _PT: ...
|
||||
|
||||
|
||||
class ThreadPool(Pool, ContextManager[ThreadPool]):
|
||||
|
||||
def __init__(self, processes: Optional[int] = ...,
|
||||
initializer: Optional[Callable[..., Any]] = ...,
|
||||
initargs: Iterable[Any] = ...) -> None: ...
|
||||
def __init__(
|
||||
self, processes: Optional[int] = ..., initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ...
|
||||
) -> None: ...
|
||||
|
||||
# undocumented
|
||||
RUN: int
|
||||
|
||||
@@ -34,5 +34,6 @@ class BaseProcess:
|
||||
|
||||
def current_process() -> BaseProcess: ...
|
||||
def active_children() -> List[BaseProcess]: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
def parent_process() -> Optional[BaseProcess]: ...
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import queue
|
||||
from typing import Any, Generic, Optional, TypeVar
|
||||
|
||||
import queue
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class Queue(queue.Queue[_T]):
|
||||
# FIXME: `ctx` is a circular dependency and it's not actually optional.
|
||||
|
||||
@@ -15,7 +15,6 @@ if sys.version_info >= (3, 8):
|
||||
def size(self) -> int: ...
|
||||
def close(self) -> None: ...
|
||||
def unlink(self) -> None: ...
|
||||
|
||||
class ShareableList(Generic[_SLT]):
|
||||
shm: SharedMemory
|
||||
def __init__(self, sequence: Optional[Iterable[_SLT]] = ..., *, name: Optional[str] = ...) -> None: ...
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
from ctypes import _CData
|
||||
from typing import Any, List, Optional, Sequence, Type, Union, overload
|
||||
|
||||
from multiprocessing.synchronize import _LockLike
|
||||
from multiprocessing.context import BaseContext
|
||||
from multiprocessing.synchronize import _LockLike
|
||||
from typing import Any, List, Optional, Sequence, Type, Union, overload
|
||||
|
||||
class _Array:
|
||||
value: Any = ...
|
||||
|
||||
def __init__(self, typecode_or_type: Union[str, Type[_CData]], size_or_initializer: Union[int, Sequence[Any]], *, lock: Union[bool, _LockLike] = ...) -> None: ...
|
||||
def __init__(
|
||||
self,
|
||||
typecode_or_type: Union[str, Type[_CData]],
|
||||
size_or_initializer: Union[int, Sequence[Any]],
|
||||
*,
|
||||
lock: Union[bool, _LockLike] = ...,
|
||||
) -> None: ...
|
||||
def acquire(self) -> bool: ...
|
||||
def release(self) -> bool: ...
|
||||
def get_lock(self) -> _LockLike: ...
|
||||
def get_obj(self) -> Any: ...
|
||||
|
||||
@overload
|
||||
def __getitem__(self, key: int) -> Any: ...
|
||||
@overload
|
||||
@@ -20,7 +23,7 @@ class _Array:
|
||||
def __getslice__(self, start: int, stop: int) -> Any: ...
|
||||
def __setitem__(self, key: int, value: Any) -> None: ...
|
||||
|
||||
class _Value():
|
||||
class _Value:
|
||||
value: Any = ...
|
||||
def __init__(self, typecode_or_type: Union[str, Type[_CData]], *args: Any, lock: Union[bool, _LockLike] = ...) -> None: ...
|
||||
def get_lock(self) -> _LockLike: ...
|
||||
@@ -33,10 +36,8 @@ def Array(
|
||||
size_or_initializer: Union[int, Sequence[Any]],
|
||||
*,
|
||||
lock: Union[bool, _LockLike] = ...,
|
||||
ctx: Optional[BaseContext] = ...) -> _Array: ...
|
||||
|
||||
ctx: Optional[BaseContext] = ...,
|
||||
) -> _Array: ...
|
||||
def Value(
|
||||
typecode_or_type: Union[str, Type[_CData]],
|
||||
*args: Any,
|
||||
lock: Union[bool, _LockLike] = ...,
|
||||
ctx: Optional[BaseContext] = ...) -> _Value: ...
|
||||
typecode_or_type: Union[str, Type[_CData]], *args: Any, lock: Union[bool, _LockLike] = ..., ctx: Optional[BaseContext] = ...
|
||||
) -> _Value: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from typing import Any, Dict, List, Mapping, Optional, Sequence
|
||||
from types import ModuleType
|
||||
from typing import Any, Dict, List, Mapping, Optional, Sequence
|
||||
|
||||
WINEXE: bool
|
||||
WINSERVICE: bool
|
||||
@@ -10,9 +10,12 @@ 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: ...
|
||||
|
||||
# undocumented
|
||||
def _main(fd: int) -> Any: ...
|
||||
def get_preparation_data(name: str) -> Dict[str, Any]: ...
|
||||
|
||||
old_main_modules: List[ModuleType]
|
||||
|
||||
def prepare(data: Mapping[str, Any]) -> None: ...
|
||||
def import_main_path(main_path: str) -> None: ...
|
||||
|
||||
@@ -1,46 +1,32 @@
|
||||
from typing import Any, Callable, ContextManager, Optional, Union
|
||||
|
||||
from multiprocessing.context import BaseContext
|
||||
import threading
|
||||
import sys
|
||||
import threading
|
||||
from multiprocessing.context import BaseContext
|
||||
from typing import Any, Callable, ContextManager, Optional, Union
|
||||
|
||||
_LockLike = Union[Lock, RLock]
|
||||
|
||||
class Barrier(threading.Barrier):
|
||||
def __init__(self,
|
||||
parties: int,
|
||||
action: Optional[Callable[..., Any]] = ...,
|
||||
timeout: Optional[float] = ...,
|
||||
*
|
||||
ctx: BaseContext) -> None: ...
|
||||
def __init__(
|
||||
self, parties: int, action: Optional[Callable[..., Any]] = ..., timeout: Optional[float] = ..., *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: Optional[_LockLike] = ..., *, 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_for(self, predicate: Callable[[], bool], timeout: Optional[float] = ...) -> bool: ...
|
||||
def acquire(self, block: bool = ..., timeout: Optional[float] = ...) -> bool: ...
|
||||
def release(self) -> None: ...
|
||||
|
||||
class Event(ContextManager[bool]):
|
||||
def __init__(self,
|
||||
lock: Optional[_LockLike] = ...,
|
||||
*,
|
||||
ctx: BaseContext) -> None: ...
|
||||
def __init__(self, lock: Optional[_LockLike] = ..., *, ctx: BaseContext) -> None: ...
|
||||
def is_set(self) -> bool: ...
|
||||
def set(self) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
@@ -57,7 +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: Optional[float] = ...) -> bool: ...
|
||||
def release(self) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user