diff --git a/stdlib/VERSIONS b/stdlib/VERSIONS index b78038f26..aa12ba88f 100644 --- a/stdlib/VERSIONS +++ b/stdlib/VERSIONS @@ -174,6 +174,7 @@ modulefinder: 2.7- msilib: 2.7- msvcrt: 2.7- multiprocessing: 2.7- +multiprocessing.shared_memory: 3.8- netrc: 2.7- nis: 2.7- nntplib: 2.7- diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index c59ee55d3..3fafd8891 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -9,6 +9,26 @@ from typing_extensions import Literal if sys.version_info >= (3, 9): from types import GenericAlias +__all__ = [ + "Mailbox", + "Maildir", + "mbox", + "MH", + "Babyl", + "MMDF", + "Message", + "MaildirMessage", + "mboxMessage", + "MHMessage", + "BabylMessage", + "MMDFMessage", + "Error", + "NoSuchMailboxError", + "NotEmptyError", + "ExternalClashError", + "FormatError", +] + _T = TypeVar("_T") _MessageT = TypeVar("_MessageT", bound=Message) _MessageData = Union[email.message.Message, bytes, str, IO[str], IO[bytes]] diff --git a/stdlib/mailcap.pyi b/stdlib/mailcap.pyi index 56218d137..7bf2ebd1b 100644 --- a/stdlib/mailcap.pyi +++ b/stdlib/mailcap.pyi @@ -2,6 +2,8 @@ from typing import Mapping, Sequence, Union _Cap = dict[str, Union[str, int]] +__all__ = ["getcaps", "findmatch"] + def findmatch( caps: Mapping[str, list[_Cap]], MIMEtype: str, key: str = ..., filename: str = ..., plist: Sequence[str] = ... ) -> tuple[str | None, _Cap | None]: ... diff --git a/stdlib/mimetypes.pyi b/stdlib/mimetypes.pyi index 5b5d07830..e51b7cdf3 100644 --- a/stdlib/mimetypes.pyi +++ b/stdlib/mimetypes.pyi @@ -2,6 +2,22 @@ import sys from _typeshed import StrPath from typing import IO, Sequence +__all__ = [ + "knownfiles", + "inited", + "MimeTypes", + "guess_type", + "guess_all_extensions", + "guess_extension", + "add_type", + "init", + "read_mime_types", + "suffix_map", + "encodings_map", + "types_map", + "common_types", +] + if sys.version_info >= (3, 8): def guess_type(url: StrPath, strict: bool = ...) -> tuple[str | None, str | None]: ... diff --git a/stdlib/multiprocessing/__init__.pyi b/stdlib/multiprocessing/__init__.pyi index 000fed79f..979176c47 100644 --- a/stdlib/multiprocessing/__init__.pyi +++ b/stdlib/multiprocessing/__init__.pyi @@ -29,6 +29,86 @@ if sys.version_info >= (3, 8): if sys.platform != "win32": from multiprocessing.context import ForkContext, ForkServerContext +if sys.version_info >= (3, 8): + __all__ = [ + "Array", + "AuthenticationError", + "Barrier", + "BoundedSemaphore", + "BufferTooShort", + "Condition", + "Event", + "JoinableQueue", + "Lock", + "Manager", + "Pipe", + "Pool", + "Process", + "ProcessError", + "Queue", + "RLock", + "RawArray", + "RawValue", + "Semaphore", + "SimpleQueue", + "TimeoutError", + "Value", + "active_children", + "allow_connection_pickling", + "cpu_count", + "current_process", + "freeze_support", + "get_all_start_methods", + "get_context", + "get_logger", + "get_start_method", + "log_to_stderr", + "reducer", + "set_executable", + "set_forkserver_preload", + "set_start_method", + ] +else: + __all__ = [ + "Array", + "AuthenticationError", + "Barrier", + "BoundedSemaphore", + "BufferTooShort", + "Condition", + "Event", + "JoinableQueue", + "Lock", + "Manager", + "Pipe", + "Pool", + "Process", + "ProcessError", + "Queue", + "RLock", + "RawArray", + "RawValue", + "Semaphore", + "SimpleQueue", + "TimeoutError", + "Value", + "active_children", + "allow_connection_pickling", + "cpu_count", + "current_process", + "freeze_support", + "get_all_start_methods", + "get_context", + "get_logger", + "get_start_method", + "log_to_stderr", + "parent_process", + "reducer", + "set_executable", + "set_forkserver_preload", + "set_start_method", + ] + # The following type aliases can be used to annotate the return values of # the corresponding functions. They are not defined at runtime. # diff --git a/stdlib/multiprocessing/connection.pyi b/stdlib/multiprocessing/connection.pyi index d89821476..5db6fa4cd 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -3,19 +3,15 @@ import sys import types from _typeshed import Self from typing import Any, Iterable, Union +from typing_extensions import SupportsIndex -if sys.version_info >= (3, 8): - from typing import SupportsIndex +__all__ = ["Client", "Listener", "Pipe", "wait"] # https://docs.python.org/3/library/multiprocessing.html#address-formats _Address = Union[str, tuple[str, int]] class _ConnectionBase: - if sys.version_info >= (3, 8): - def __init__(self, handle: SupportsIndex, readable: bool = ..., writable: bool = ...) -> None: ... - else: - def __init__(self, handle: int, readable: bool = ..., writable: bool = ...) -> None: ... - + def __init__(self, handle: SupportsIndex, readable: bool = ..., writable: bool = ...) -> None: ... @property def closed(self) -> bool: ... # undocumented @property diff --git a/stdlib/multiprocessing/dummy/__init__.pyi b/stdlib/multiprocessing/dummy/__init__.pyi index b4d1c8404..70f1cc261 100644 --- a/stdlib/multiprocessing/dummy/__init__.pyi +++ b/stdlib/multiprocessing/dummy/__init__.pyi @@ -4,6 +4,25 @@ import weakref from queue import Queue as Queue from typing import Any, Callable, Iterable, Mapping, Sequence +__all__ = [ + "Process", + "current_process", + "active_children", + "freeze_support", + "Lock", + "RLock", + "Semaphore", + "BoundedSemaphore", + "Condition", + "Event", + "Barrier", + "Queue", + "Manager", + "Pipe", + "Pool", + "JoinableQueue", +] + JoinableQueue = Queue Barrier = threading.Barrier BoundedSemaphore = threading.BoundedSemaphore diff --git a/stdlib/multiprocessing/dummy/connection.pyi b/stdlib/multiprocessing/dummy/connection.pyi index 26413cb75..d1ff83961 100644 --- a/stdlib/multiprocessing/dummy/connection.pyi +++ b/stdlib/multiprocessing/dummy/connection.pyi @@ -3,6 +3,8 @@ from queue import Queue from types import TracebackType from typing import Any, Union +__all__ = ["Client", "Listener", "Pipe"] + families: list[None] _Address = Union[str, tuple[str, int]] diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index fd91e49d9..fef3e1e21 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -11,8 +11,12 @@ from .context import BaseContext if sys.version_info >= (3, 8): from .shared_memory import _SLT, ShareableList, SharedMemory + __all__ = ["BaseManager", "SyncManager", "BaseProxy", "Token", "SharedMemoryManager"] + _SharedMemory = SharedMemory _ShareableList = ShareableList +else: + __all__ = ["BaseManager", "SyncManager", "BaseProxy", "Token"] if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/multiprocessing/process.pyi b/stdlib/multiprocessing/process.pyi index 2e76ea551..f4464c08c 100644 --- a/stdlib/multiprocessing/process.pyi +++ b/stdlib/multiprocessing/process.pyi @@ -1,6 +1,11 @@ import sys from typing import Any, Callable, Mapping +if sys.version_info >= (3, 8): + __all__ = ["BaseProcess", "current_process", "active_children", "parent_process"] +else: + __all__ = ["BaseProcess", "current_process", "active_children"] + class BaseProcess: name: str daemon: bool diff --git a/stdlib/multiprocessing/queues.pyi b/stdlib/multiprocessing/queues.pyi index ed544470c..1d31fa694 100644 --- a/stdlib/multiprocessing/queues.pyi +++ b/stdlib/multiprocessing/queues.pyi @@ -5,6 +5,8 @@ from typing import Any, Generic, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias +__all__ = ["Queue", "SimpleQueue", "JoinableQueue"] + _T = TypeVar("_T") class Queue(queue.Queue[_T]): diff --git a/stdlib/multiprocessing/shared_memory.pyi b/stdlib/multiprocessing/shared_memory.pyi index 56a5f7bc7..a4c4fd071 100644 --- a/stdlib/multiprocessing/shared_memory.pyi +++ b/stdlib/multiprocessing/shared_memory.pyi @@ -5,30 +5,31 @@ from typing import Any, Generic, Iterable, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias +__all__ = ["SharedMemory", "ShareableList"] + _SLT = TypeVar("_SLT", int, float, bool, str, bytes, None) -if sys.version_info >= (3, 8): - class SharedMemory: - def __init__(self, name: str | None = ..., create: bool = ..., size: int = ...) -> None: ... - @property - def buf(self) -> memoryview: ... - @property - def name(self) -> str: ... - @property - def size(self) -> int: ... - def close(self) -> None: ... - def unlink(self) -> None: ... +class SharedMemory: + def __init__(self, name: str | None = ..., create: bool = ..., size: int = ...) -> None: ... + @property + def buf(self) -> memoryview: ... + @property + def name(self) -> str: ... + @property + def size(self) -> int: ... + def close(self) -> None: ... + def unlink(self) -> None: ... - class ShareableList(Generic[_SLT]): - shm: SharedMemory - 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: Self) -> tuple[Self, tuple[_SLT, ...]]: ... - def __len__(self) -> int: ... - @property - def format(self) -> str: ... - def count(self, value: _SLT) -> int: ... - def index(self, value: _SLT) -> int: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... +class ShareableList(Generic[_SLT]): + shm: SharedMemory + 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: Self) -> tuple[Self, tuple[_SLT, ...]]: ... + def __len__(self) -> int: ... + @property + def format(self) -> str: ... + def count(self, value: _SLT) -> int: ... + def index(self, value: _SLT) -> int: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... diff --git a/stdlib/multiprocessing/sharedctypes.pyi b/stdlib/multiprocessing/sharedctypes.pyi index 440217a6e..9b0407e2d 100644 --- a/stdlib/multiprocessing/sharedctypes.pyi +++ b/stdlib/multiprocessing/sharedctypes.pyi @@ -6,6 +6,8 @@ from multiprocessing.synchronize import _LockLike from typing import Any, Generic, Protocol, TypeVar, overload from typing_extensions import Literal +__all__ = ["RawValue", "RawArray", "Value", "Array", "copy", "synchronized"] + _T = TypeVar("_T") _CT = TypeVar("_CT", bound=_CData) diff --git a/stdlib/multiprocessing/spawn.pyi b/stdlib/multiprocessing/spawn.pyi index 34c7322e0..4f981ea46 100644 --- a/stdlib/multiprocessing/spawn.pyi +++ b/stdlib/multiprocessing/spawn.pyi @@ -1,6 +1,16 @@ from types import ModuleType from typing import Any, Mapping, Sequence +__all__ = [ + "_main", + "freeze_support", + "set_executable", + "get_executable", + "get_preparation_data", + "get_command_line", + "import_main_path", +] + WINEXE: bool WINSERVICE: bool diff --git a/stdlib/multiprocessing/synchronize.pyi b/stdlib/multiprocessing/synchronize.pyi index 873bc8f40..6764b7666 100644 --- a/stdlib/multiprocessing/synchronize.pyi +++ b/stdlib/multiprocessing/synchronize.pyi @@ -4,6 +4,8 @@ from contextlib import AbstractContextManager from multiprocessing.context import BaseContext from typing import Any, Callable, Union +__all__ = ["Lock", "RLock", "Semaphore", "BoundedSemaphore", "Condition", "Event"] + _LockLike = Union[Lock, RLock] class Barrier(threading.Barrier): diff --git a/tests/stubtest_allowlists/py36.txt b/tests/stubtest_allowlists/py36.txt index 8e96850cf..884937089 100644 --- a/tests/stubtest_allowlists/py36.txt +++ b/tests/stubtest_allowlists/py36.txt @@ -30,7 +30,6 @@ io.StringIO.readline ipaddress._BaseNetwork.__init__ json.loads mmap.ACCESS_DEFAULT -multiprocessing.shared_memory (os|posix).utime plistlib.Dict.__init__ pyexpat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args diff --git a/tests/stubtest_allowlists/py37.txt b/tests/stubtest_allowlists/py37.txt index cea523107..9bb819f06 100644 --- a/tests/stubtest_allowlists/py37.txt +++ b/tests/stubtest_allowlists/py37.txt @@ -29,7 +29,6 @@ hmac.HMAC.__init__ http.server.SimpleHTTPRequestHandler.__init__ # *args is expanded ipaddress._BaseNetwork.__init__ json.loads -multiprocessing.shared_memory (os|posix).utime pyexpat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args queue.SimpleQueue.__init__ # Default C __init__ signature is wrong