8000 Add `__all__` to most modules beginning with 'q', 'r' and 's' by AlexWaygood · Pull Request #7364 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

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

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 23, 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
5 changes: 5 additions & 0 deletions stdlib/queue.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
Expand Down
2 changes: 2 additions & 0 deletions stdlib/quopri.pyi
Original file line number Diff line numb 10000 er Diff line change
@@ -1,5 +1,7 @@
from typing import BinaryIO

__all__ = ["encode", "decode", "encodestring", "decodestring"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has a comment # (Dec 1991 version)., that module is older than me


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: ...
Expand Down
56 changes: 56 additions & 0 deletions stdlib/random.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
97 changes: 97 additions & 0 deletions stdlib/re.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions stdlib/reprlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]: ...
Expand Down
2 changes: 2 additions & 0 deletions stdlib/rlcompleter.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
2 changes: 2 additions & 0 deletions stdlib/secrets.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
2 changes: 2 additions & 0 deletions stdlib/shelve.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
5 changes: 5 additions & 0 deletions stdlib/shlex.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
29 changes: 29 additions & 0 deletions stdlib/shutil.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions stdlib/smtpd.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import socket
from collections import defaultdict
from typing import Any

__all__ = ["SMTPChannel", "SMTPServer", "DebuggingServer", "PureProxy", "MailmanProxy"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MailmanProxy is gone in 3.11 (python/cpython#26617). I'll send a separate PR for that.


_Address = tuple[str, int] # (host, port)

class SMTPChannel(asynchat.async_chat):
Expand Down
34 changes: 34 additions & 0 deletions stdlib/smtplib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions stdlib/sndhdr.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from _typeshed import StrOrBytesPath
from typing import NamedTuple

__all__ = ["what", "whathdr"]

class SndHeaders(NamedTuple):
filetype: str
framerate: int
Expand Down
32 changes: 32 additions & 0 deletions stdlib/socketserver.pyi
Original file line number Diff line number Diff line change
Expand Up 9F56 @@ -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]

Expand Down
Loading
0