diff --git a/stdlib/hashlib.pyi b/stdlib/hashlib.pyi index 3b8fbeb0bf3e..4332153d281c 100644 --- a/stdlib/hashlib.pyi +++ b/stdlib/hashlib.pyi @@ -3,6 +3,27 @@ from _typeshed import ReadableBuffer, Self from typing import AbstractSet from typing_extensions import final +__all__ = ( + "md5", + "sha1", + "sha224", + "sha256", + "sha384", + "sha512", + "blake2b", + "blake2s", + "sha3_224", + "sha3_256", + "sha3_384", + "sha3_512", + "shake_128", + "shake_256", + "new", + "algorithms_guaranteed", + "algorithms_available", + "pbkdf2_hmac", +) + class _Hash: @property def digest_size(self) -> int: ... diff --git a/stdlib/heapq.pyi b/stdlib/heapq.pyi index cf2faf7bfc24..a7a787d44e62 100644 --- a/stdlib/heapq.pyi +++ b/stdlib/heapq.pyi @@ -2,6 +2,8 @@ from _heapq import * from _typeshed import SupportsRichComparison from typing import Any, Callable, Iterable, TypeVar +__all__ = ["heappush", "heappop", "heapify", "heapreplace", "merge", "nlargest", "nsmallest", "heappushpop"] + _S = TypeVar("_S") __about__: str diff --git a/stdlib/html/__init__.pyi b/stdlib/html/__init__.pyi index af2a80021656..109c5f4b50fb 100644 --- a/stdlib/html/__init__.pyi +++ b/stdlib/html/__init__.pyi @@ -1,4 +1,6 @@ from typing import AnyStr +__all__ = ["escape", "unescape"] + def escape(s: AnyStr, quote: bool = ...) -> AnyStr: ... def unescape(s: AnyStr) -> AnyStr: ... diff --git a/stdlib/html/entities.pyi b/stdlib/html/entities.pyi index 1743fccf32b9..be83fd1135be 100644 --- a/stdlib/html/entities.pyi +++ b/stdlib/html/entities.pyi @@ -1,3 +1,5 @@ +__all__ = ["html5", "name2codepoint", "codepoint2name", "entitydefs"] + name2codepoint: dict[str, int] html5: dict[str, str] codepoint2name: dict[int, str] diff --git a/stdlib/html/parser.pyi b/stdlib/html/parser.pyi index 60e0de51d3b8..1731a345920b 100644 --- a/stdlib/html/parser.pyi +++ b/stdlib/html/parser.pyi @@ -1,6 +1,8 @@ from _markupbase import ParserBase from typing import Pattern +__all__ = ["HTMLParser"] + class HTMLParser(ParserBase): def __init__(self, *, convert_charrefs: bool = ...) -> None: ... def feed(self, data: str) -> None: ... diff --git a/stdlib/http/__init__.pyi b/stdlib/http/__init__.pyi index 93895549cb2a..822cc0932939 100644 --- a/stdlib/http/__init__.pyi +++ b/stdlib/http/__init__.pyi @@ -2,6 +2,8 @@ import sys from enum import IntEnum from typing_extensions import Literal +__all__ = ["HTTPStatus"] + class HTTPStatus(IntEnum): @property def phrase(self) -> str: ... diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index 071c49470462..93f132d678f9 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -7,6 +7,28 @@ from _typeshed import Self, WriteableBuffer from socket import socket from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, Mapping, Protocol, TypeVar, Union, overload +__all__ = [ + "HTTPResponse", + "HTTPConnection", + "HTTPException", + "NotConnected", + "UnknownProtocol", + "UnknownTransferEncoding", + "UnimplementedFileMode", + "IncompleteRead", + "InvalidURL", + "ImproperConnectionState", + "CannotSendRequest", + "CannotSendHeader", + "ResponseNotReady", + "BadStatusLine", + "LineTooLong", + "RemoteDisconnected", + "error", + "responses", + "HTTPSConnection", +] + _DataType = Union[bytes, IO[Any], Iterable[bytes], str] _T = TypeVar("_T") diff --git a/stdlib/http/cookiejar.pyi b/stdlib/http/cookiejar.pyi index 02fadd87349a..4fb1c38c6ab8 100644 --- a/stdlib/http/cookiejar.pyi +++ b/stdlib/http/cookiejar.pyi @@ -4,6 +4,17 @@ from http.client import HTTPResponse from typing import ClassVar, Iterable, Iterator, Pattern, Sequence, TypeVar, overload from urllib.request import Request +__all__ = [ + "Cookie", + "CookieJar", + "CookiePolicy", + "DefaultCookiePolicy", + "FileCookieJar", + "LWPCookieJar", + "LoadError", + "MozillaCookieJar", +] + _T = TypeVar("_T") class LoadError(OSError): ... diff --git a/stdlib/http/cookies.pyi b/stdlib/http/cookies.pyi index 740a41a819ed..11760ecf4287 100644 --- a/stdlib/http/cookies.pyi +++ b/stdlib/http/cookies.pyi @@ -4,6 +4,8 @@ from typing import Any, Generic, Iterable, Mapping, TypeVar, Union, overload if sys.version_info >= (3, 9): from types import GenericAlias +__all__ = ["CookieError", "BaseCookie", "SimpleCookie"] + _DataType = Union[str, Mapping[str, Union[str, Morsel[Any]]]] _T = TypeVar("_T") diff --git a/stdlib/http/server.pyi b/stdlib/http/server.pyi index df9561ce5412..0512ab5f739f 100644 --- a/stdlib/http/server.pyi +++ b/stdlib/http/server.pyi @@ -5,6 +5,8 @@ import sys from _typeshed import StrPath, SupportsRead, SupportsWrite from typing import Any, AnyStr, BinaryIO, ClassVar, Mapping, Sequence +__all__ = ["HTTPServer", "ThreadingHTTPServer", "BaseHTTPRequestHandler", "SimpleHTTPRequestHandler", "CGIHTTPRequestHandler"] + class HTTPServer(socketserver.TCPServer): server_name: str server_port: int diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index c36e5cee4fb2..e85e7d4ad90a 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -8,6 +8,8 @@ from types import TracebackType from typing import IO, Any, Callable, Pattern, Union from typing_extensions import Literal +__all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple", "Int2AP", "ParseFlags", "Time2Internaldate", "IMAP4_SSL"] + # TODO: Commands should use their actual return types, not this type alias. # E.g. Tuple[Literal["OK"], List[bytes]] _CommandResults = tuple[str, list[Any]] diff --git a/stdlib/imghdr.pyi b/stdlib/imghdr.pyi index 4515cf2269b0..af046e899326 100644 --- a/stdlib/imghdr.pyi +++ b/stdlib/imghdr.pyi @@ -1,6 +1,8 @@ from _typeshed import StrPath from typing import Any, BinaryIO, Callable, Protocol, overload +__all__ = ["what"] + class _ReadableBinary(Protocol): def tell(self) -> int: ... def read(self, size: int) -> bytes: ... diff --git a/stdlib/importlib/__init__.pyi b/stdlib/importlib/__init__.pyi index 1b91cc55f2df..0e99786775b0 100644 --- a/stdlib/importlib/__init__.pyi +++ b/stdlib/importlib/__init__.pyi @@ -2,6 +2,8 @@ from importlib.abc import Loader from types import ModuleType from typing import Mapping, Sequence +__all__ = ["__import__", "import_module", "invalidate_caches", "reload"] + # Signature of `builtins.__import__` should be kept identical to `importlib.__import__` def __import__( name: str, diff --git a/stdlib/importlib/resources.pyi b/stdlib/importlib/resources.pyi index 38b891fb72e7..cee3259332ff 100644 --- a/stdlib/importlib/resources.pyi +++ b/stdlib/importlib/resources.pyi @@ -5,6 +5,38 @@ from pathlib import Path from types import ModuleType from typing import Any, BinaryIO, Iterator, TextIO, Union +if sys.version_info >= (3, 10): + __all__ = [ + "Package", + "Resource", + "ResourceReader", + "as_file", + "contents", + "files", + "is_resource", + "open_binary", + "open_text", + "path", + "read_binary", + "read_text", + ] +elif sys.version_info >= (3, 9): + __all__ = [ + "Package", + "Resource", + "as_file", + "contents", + "files", + "is_resource", + "open_binary", + "open_text", + "path", + "read_binary", + "read_text", + ] +else: + __all__ = ["Package", "Resource", "contents", "is_resource", "open_binary", "open_text", "path", "read_binary", "read_text"] + Package = Union[str, ModuleType] Resource = Union[str, os.PathLike[Any]] diff --git a/stdlib/io.pyi b/stdlib/io.pyi index 659248015e25..c32691edb686 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -7,6 +7,50 @@ from types import TracebackType from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, TextIO from typing_extensions import Literal +if sys.version_info >= (3, 8): + __all__ = [ + "BlockingIOError", + "open", + "open_code", + "IOBase", + "RawIOBase", + "FileIO", + "BytesIO", + "StringIO", + "BufferedIOBase", + "BufferedReader", + "BufferedWriter", + "BufferedRWPair", + "BufferedRandom", + "TextIOBase", + "TextIOWrapper", + "UnsupportedOperation", + "SEEK_SET", + "SEEK_CUR", + "SEEK_END", + ] +else: + __all__ = [ + "BlockingIOError", + "open", + "IOBase", + "RawIOBase", + "FileIO", + "BytesIO", + "StringIO", + "BufferedIOBase", + "BufferedReader", + "BufferedWriter", + "BufferedRWPair", + "BufferedRandom", + "TextIOBase", + "TextIOWrapper", + "UnsupportedOperation", + "SEEK_SET", + "SEEK_CUR", + "SEEK_END", + ] + DEFAULT_BUFFER_SIZE: Literal[8192] SEEK_SET: Literal[0]