Add __all__ to most modules beginning with 'q', 'r' and 's' (#7364)

This commit is contained in:
Alex Waygood
2022-02-23 00:51:54 +00:00
committed by GitHub
parent 240628c4dd
commit a3bb5af4a0
19 changed files with 364 additions and 0 deletions

View File

@@ -5,6 +5,11 @@ from typing import Any, Generic, TypeVar
if sys.version_info >= (3, 9):
from types import GenericAlias
if sys.version_info >= (3, 7):
__all__ = ["Empty", "Full", "Queue", "PriorityQueue", "LifoQueue", "SimpleQueue"]
else:
__all__ = ["Empty", "Full", "Queue", "PriorityQueue", "LifoQueue"]
_T = TypeVar("_T")
class Empty(Exception): ...

View File

@@ -1,5 +1,7 @@
from typing import BinaryIO
__all__ = ["encode", "decode", "encodestring", "decodestring"]
def encode(input: BinaryIO, output: BinaryIO, quotetabs: int, header: int = ...) -> None: ...
def encodestring(s: bytes, quotetabs: int = ..., header: int = ...) -> bytes: ...
def decode(input: BinaryIO, output: BinaryIO, header: int = ...) -> None: ...

View File

@@ -5,6 +5,62 @@ from collections.abc import Callable, Iterable, MutableSequence, Sequence, Set a
from fractions import Fraction
from typing import Any, ClassVar, NoReturn, TypeVar
if sys.version_info >= (3, 9):
__all__ = [
"Random",
"SystemRandom",
"betavariate",
"choice",
"choices",
"expovariate",
"gammavariate",
"gauss",
"getrandbits",
"getstate",
"lognormvariate",
"normalvariate",
"paretovariate",
"randbytes",
"randint",
"random",
"randrange",
"sample",
"seed",
"setstate",
"shuffle",
"triangular",
"uniform",
"vonmisesvariate",
"weibullvariate",
]
else:
__all__ = [
"Random",
"seed",
"random",
"uniform",
"randint",
"choice",
"sample",
"randrange",
"shuffle",
"normalvariate",
"lognormvariate",
"expovariate",
"vonmisesvariate",
"gammavariate",
"triangular",
"gauss",
"betavariate",
"paretovariate",
"weibullvariate",
"getstate",
"setstate",
"getrandbits",
"choices",
"SystemRandom",
]
_T = TypeVar("_T")
class Random(_random.Random):

View File

@@ -9,6 +9,103 @@ if sys.version_info >= (3, 7):
else:
from typing import Match, Pattern
if sys.version_info >= (3, 11):
__all__ = [
"match",
"fullmatch",
"search",
"sub",
"subn",
"split",
"findall",
"finditer",
"compile",
"purge",
"template",
"escape",
"error",
"Pattern",
"Match",
"A",
"I",
"L",
"M",
"S",
"X",
"U",
"ASCII",
"IGNORECASE",
"LOCALE",
"MULTILINE",
"DOTALL",
"VERBOSE",
"UNICODE",
"RegexFlag",
"NOFLAG",
]
elif sys.version_info >= (3, 8):
__all__ = [
"match",
"fullmatch",
"search",
"sub",
"subn",
"split",
"findall",
"finditer",
"compile",
"purge",
"template",
"escape",
"error",
"Pattern",
"Match",
"A",
"I",
"L",
"M",
"S",
"X",
"U",
"ASCII",
"IGNORECASE",
"LOCALE",
"MULTILINE",
"DOTALL",
"VERBOSE",
"UNICODE",
]
else:
__all__ = [
"match",
"fullmatch",
"search",
"sub",
"subn",
"split",
"findall",
"finditer",
"compile",
"purge",
"template",
"escape",
"error",
"A",
"I",
"L",
"M",
"S",
"X",
"U",
"ASCII",
"IGNORECASE",
"LOCALE",
"MULTILINE",
"DOTALL",
"VERBOSE",
"UNICODE",
]
class RegexFlag(enum.IntFlag):
A: int
ASCII: int

View File

@@ -2,6 +2,8 @@ from array import array
from collections import deque
from typing import Any, Callable
__all__ = ["Repr", "repr", "recursive_repr"]
_ReprFunc = Callable[[Any], str]
def recursive_repr(fillvalue: str = ...) -> Callable[[_ReprFunc], _ReprFunc]: ...

View File

@@ -1,5 +1,7 @@
from typing import Any
__all__ = ["Completer"]
class Completer:
def __init__(self, namespace: dict[str, Any] | None = ...) -> None: ...
def complete(self, text: str, state: int) -> str | None: ...

View File

@@ -3,6 +3,8 @@ from hmac import compare_digest as compare_digest
from random import SystemRandom as SystemRandom
from typing import TypeVar
__all__ = ["choice", "randbelow", "randbits", "SystemRandom", "token_bytes", "token_hex", "token_urlsafe", "compare_digest"]
_T = TypeVar("_T")
def randbelow(exclusive_upper_bound: int) -> int: ...

View File

@@ -4,6 +4,8 @@ from dbm import _TFlags
from types import TracebackType
from typing import TypeVar, overload
__all__ = ["Shelf", "BsdDbShelf", "DbfilenameShelf", "open"]
_T = TypeVar("_T")
_VT = TypeVar("_VT")

View File

@@ -2,6 +2,11 @@ import sys
from _typeshed import Self
from typing import Iterable, TextIO
if sys.version_info >= (3, 8):
__all__ = ["shlex", "split", "quote", "join"]
else:
__all__ = ["shlex", "split", "quote"]
def split(s: str, comments: bool = ..., posix: bool = ...) -> list[str]: ...
if sys.version_info >= (3, 8):

View File

@@ -3,6 +3,35 @@ import sys
from _typeshed import BytesPath, StrOrBytesPath, StrPath, SupportsRead, SupportsWrite
from typing import Any, AnyStr, Callable, Iterable, NamedTuple, Sequence, TypeVar, Union, overload
__all__ = [
"copyfileobj",
"copyfile",
"copymode",
"copystat",
"copy",
"copy2",
"copytree",
"move",
"rmtree",
"Error",
"SpecialFileError",
"ExecError",
"make_archive",
"get_archive_formats",
"register_archive_format",
"unregister_archive_format",
"get_unpack_formats",
"register_unpack_format",
"unregister_unpack_format",
"unpack_archive",
"ignore_patterns",
"chown",
"which",
"get_terminal_size",
"SameFileError",
"disk_usage",
]
_StrOrBytesPathT = TypeVar("_StrOrBytesPathT", bound=StrOrBytesPath)
_StrPathT = TypeVar("_StrPathT", bound=StrPath)
# Return value of some functions that may either return a path-like object that was passed in or

View File

@@ -4,6 +4,8 @@ import socket
from collections import defaultdict
from typing import Any
__all__ = ["SMTPChannel", "SMTPServer", "DebuggingServer", "PureProxy", "MailmanProxy"]
_Address = tuple[str, int] # (host, port)
class SMTPChannel(asynchat.async_chat):

View File

@@ -6,6 +6,40 @@ from ssl import SSLContext
from types import TracebackType
from typing import Any, Pattern, Protocol, Sequence, Union, overload
if sys.version_info >= (3, 7):
__all__ = [
"SMTPException",
"SMTPNotSupportedError",
"SMTPServerDisconnected",
"SMTPResponseException",
"SMTPSenderRefused",
"SMTPRecipientsRefused",
"SMTPDataError",
"SMTPConnectError",
"SMTPHeloError",
"SMTPAuthenticationError",
"quoteaddr",
"quotedata",
"SMTP",
"SMTP_SSL",
]
else:
__all__ = [
"SMTPException",
"SMTPServerDisconnected",
"SMTPResponseException",
"SMTPSenderRefused",
"SMTPRecipientsRefused",
"SMTPDataError",
"SMTPConnectError",
"SMTPHeloError",
"SMTPAuthenticationError",
"quoteaddr",
"quotedata",
"SMTP",
"SMTP_SSL",
]
_Reply = tuple[int, bytes]
_SendErrs = dict[str, _Reply]
# Should match source_address for socket.create_connection

View File

@@ -1,6 +1,8 @@
from _typeshed import StrOrBytesPath
from typing import NamedTuple
__all__ = ["what", "whathdr"]
class SndHeaders(NamedTuple):
filetype: str
framerate: int

View File

@@ -4,6 +4,38 @@ from _typeshed import Self
from socket import socket as _socket
from typing import Any, BinaryIO, Callable, ClassVar, Union
if sys.platform == "win32":
__all__ = [
"BaseServer",
"TCPServer",
"UDPServer",
"ThreadingUDPServer",
"ThreadingTCPServer",
"BaseRequestHandler",
"StreamRequestHandler",
"DatagramRequestHandler",
"ThreadingMixIn",
]
else:
__all__ = [
"BaseServer",
"TCPServer",
"UDPServer",
"ThreadingUDPServer",
"ThreadingTCPServer",
"BaseRequestHandler",
"StreamRequestHandler",
"DatagramRequestHandler",
"ThreadingMixIn",
"ForkingUDPServer",
"ForkingTCPServer",
"ForkingMixIn",
"UnixStreamServer",
"UnixDatagramServer",
"ThreadingUnixStreamServer",
"ThreadingUnixDatagramServer",
]
_RequestType = Union[_socket, tuple[bytes, _socket]]
_AddressType = Union[tuple[str, int], str]

View File

@@ -4,6 +4,65 @@ from decimal import Decimal
from fractions import Fraction
from typing import Any, Hashable, Iterable, NamedTuple, Sequence, SupportsFloat, TypeVar, Union
if sys.version_info >= (3, 10):
__all__ = [
"NormalDist",
"StatisticsError",
"correlation",
"covariance",
"fmean",
"geometric_mean",
"harmonic_mean",
"linear_regression",
"mean",
"median",
"median_grouped",
"median_high",
"median_low",
"mode",
"multimode",
"pstdev",
"pvariance",
"quantiles",
"stdev",
"variance",
]
elif sys.version_info >= (3, 8):
__all__ = [
"NormalDist",
"StatisticsError",
"fmean",
"geometric_mean",
"harmonic_mean",
"mean",
"median",
"median_grouped",
"median_high",
"median_low",
"mode",
"multimode",
"pstdev",
"pvariance",
"quantiles",
"stdev",
"variance",
]
else:
__all__ = [
"StatisticsError",
"pstdev",
"pvariance",
"stdev",
"variance",
"median",
"median_low",
"median_high",
"median_grouped",
"mean",
"mode",
"harmonic_mean",
]
# Most functions in this module accept homogeneous collections of one of these types
_Number = Union[float, Decimal, Fraction]
_NumberT = TypeVar("_NumberT", float, Decimal, Fraction)

View File

@@ -7,6 +7,21 @@ if sys.version_info >= (3, 8):
else:
from typing import Pattern
__all__ = [
"ascii_letters",
"ascii_lowercase",
"ascii_uppercase",
"capwords",
"digits",
"hexdigits",
"octdigits",
"printable",
"punctuation",
"whitespace",
"Formatter",
"Template",
]
ascii_letters: str
ascii_lowercase: str
ascii_uppercase: str

View File

@@ -2,6 +2,8 @@ import sys
from _typeshed import ReadableBuffer, WriteableBuffer
from typing import Any, Iterator
__all__ = ["calcsize", "pack", "pack_into", "unpack", "unpack_from", "iter_unpack", "Struct", "error"]
class error(Exception): ...
def pack(fmt: str | bytes, *v: Any) -> bytes: ...

View File

@@ -1,6 +1,8 @@
import sys
from typing import Any, Sequence
__all__ = ["symtable", "SymbolTable", "Class", "Function", "Symbol"]
def symtable(code: str, filename: str, compile_type: str) -> SymbolTable: ...
class SymbolTable:

View File

@@ -1,5 +1,19 @@
from typing import IO, Any, overload
__all__ = [
"get_config_h_filename",
"get_config_var",
"get_config_vars",
"get_makefile_filename",
"get_path",
"get_path_names",
"get_paths",
"get_platform",
"get_python_version",
"get_scheme_names",
"parse_config_h",
]
def get_config_var(name: str) -> str | None: ...
@overload
def get_config_vars() -> dict[str, Any]: ...