Skip to content

Add __all__ for modules beginning with 'h' and 'i' #7327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions stdlib/hashlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
2 changes: 2 additions & 0 deletions stdlib/heapq.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions stdlib/html/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import AnyStr

__all__ = ["escape", "unescape"]

def escape(s: AnyStr, quote: bool = ...) -> AnyStr: ...
def unescape(s: AnyStr) -> AnyStr: ...
2 changes: 2 additions & 0 deletions stdlib/html/entities.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
__all__ = ["html5", "name2codepoint", "codepoint2name", "entitydefs"]

name2codepoint: dict[str, int]
html5: dict[str, str]
codepoint2name: dict[int, str]
Expand Down
2 changes: 2 additions & 0 deletions stdlib/html/parser.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
Expand Down
2 changes: 2 additions & 0 deletions stdlib/http/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
22 changes: 22 additions & 0 deletions stdlib/http/client.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
11 changes: 11 additions & 0 deletions stdlib/http/cookiejar.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
Expand Down
2 changes: 2 additions & 0 deletions stdlib/http/cookies.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 2 additions & 0 deletions stdlib/http/server.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions stdlib/imaplib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down
2 changes: 2 additions & 0 deletions stdlib/imghdr.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
Expand Down
2 changes: 2 additions & 0 deletions stdlib/importlib/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
32 changes: 32 additions & 0 deletions stdlib/importlib/resources.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]]

Expand Down
44 changes: 44 additions & 0 deletions stdlib/io.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down