Skip to content

Add __all__ to most modules beginning with 'n', 'o' and 'p' #7345

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 2 commits into from
Feb 22, 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
2 changes: 2 additions & 0 deletions stdlib/netrc.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from _typeshed import StrOrBytesPath
from typing import Optional

__all__ = ["netrc", "NetrcParseError"]

class NetrcParseError(Exception):
filename: str | None
lineno: int | None
Expand Down
12 changes: 12 additions & 0 deletions stdlib/nntplib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ from _typeshed import Self
from typing import IO, Any, Iterable, NamedTuple, Union
from typing_extensions import Literal

__all__ = [
"NNTP",
"NNTPError",
"NNTPReplyError",
"NNTPTemporaryError",
"NNTPPermanentError",
"NNTPProtocolError",
"NNTPDataError",
"decode_header",
"NNTP_SSL",
]

_File = Union[IO[bytes], bytes, str, None]

class NNTPError(Exception):
Expand Down
88 changes: 86 additions & 2 deletions stdlib/ntpath.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,94 @@ from posixpath import (
)
from typing import AnyStr, overload

altsep: str
if sys.version_info < (3, 7) and sys.platform == "win32":
if sys.version_info >= (3, 7) or sys.platform != "win32":
__all__ = [
"normcase",
"isabs",
"join",
"splitdrive",
"split",
"splitext",
"basename",
"dirname",
"commonprefix",
"getsize",
"getmtime",
"getatime",
"getctime",
"islink",
"exists",
"lexists",
"isdir",
"isfile",
"ismount",
"expanduser",
"expandvars",
"normpath",
"abspath",
"curdir",
"pardir",
"sep",
"pathsep",
"defpath",
"altsep",
"extsep",
"devnull",
"realpath",
"supports_unicode_filenames",
"relpath",
"samefile",
"sameopenfile",
"samestat",
"commonpath",
]
else:
__all__ = [
"normcase",
"isabs",
"join",
"splitdrive",
"split",
"splitext",
"basename",
"dirname",
"commonprefix",
"getsize",
"getmtime",
"getatime",
"getctime",
"islink",
"exists",
"lexists",
"isdir",
"isfile",
"ismount",
"expanduser",
"expandvars",
"normpath",
"abspath",
"splitunc",
"curdir",
"pardir",
"sep",
"pathsep",
"defpath",
"altsep",
"extsep",
"devnull",
"realpath",
"supports_unicode_filenames",
"relpath",
"samefile",
"sameopenfile",
"samestat",
"commonpath",
]

def splitunc(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... # deprecated

altsep: str

# First parameter is not actually pos-only,
# but must be defined as pos-only in the stub or cross-platform code doesn't type-check,
# as the parameter name is different in posixpath.join()
Expand Down
2 changes: 2 additions & 0 deletions stdlib/numbers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from abc import ABCMeta, abstractmethod
from typing import Any, SupportsFloat, overload

__all__ = ["Number", "Complex", "Real", "Rational", "Integral"]

class Number(metaclass=ABCMeta):
@abstractmethod
def __hash__(self) -> int: ...
Expand Down
116 changes: 116 additions & 0 deletions stdlib/operator.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,122 @@ import sys

from _operator import *

if sys.version_info >= (3, 11):
__all__ = [
"abs",
"add",
"and_",
"attrgetter",
"call",
"concat",
"contains",
"countOf",
"delitem",
"eq",
"floordiv",
"ge",
"getitem",
"gt",
"iadd",
"iand",
"iconcat",
"ifloordiv",
"ilshift",
"imatmul",
"imod",
"imul",
"index",
"indexOf",
"inv",
"invert",
"ior",
"ipow",
"irshift",
"is_",
"is_not",
"isub",
"itemgetter",
"itruediv",
"ixor",
"le",
"length_hint",
"lshift",
"lt",
"matmul",
"methodcaller",
"mod",
"mul",
"ne",
"neg",
"not_",
"or_",
"pos",
"pow",
"rshift",
"setitem",
"sub",
"truediv",
"truth",
"xor",
]
else:
__all__ = [
"abs",
"add",
"and_",
"attrgetter",
"concat",
"contains",
"countOf",
"delitem",
"eq",
"floordiv",
"ge",
"getitem",
"gt",
"iadd",
"iand",
"iconcat",
"ifloordiv",
"ilshift",
"imatmul",
"imod",
"imul",
"index",
"indexOf",
"inv",
"invert",
"ior",
"ipow",
"irshift",
"is_",
"is_not",
"isub",
"itemgetter",
"itruediv",
"ixor",
"le",
"length_hint",
"lshift",
"lt",
"matmul",
"methodcaller",
"mod",
"mul",
"ne",
"neg",
"not_",
"or_",
"pos",
"pow",
"rshift",
"setitem",
"sub",
"truediv",
"truth",
"xor",
]

__lt__ = lt
__le__ = le
__eq__ = eq
Expand Down
20 changes: 20 additions & 0 deletions stdlib/optparse.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
from abc import abstractmethod
from typing import IO, Any, AnyStr, Callable, Iterable, Mapping, Sequence, overload

__all__ = [
"Option",
"make_option",
"SUPPRESS_HELP",
"SUPPRESS_USAGE",
"Values",
"OptionContainer",
"OptionGroup",
"OptionParser",
"HelpFormatter",
"IndentedHelpFormatter",
"TitledHelpFormatter",
"OptParseError",
"OptionError",
"OptionConflictError",
"OptionValueError",
"BadOptionError",
"check_choice",
]

NO_DEFAULT: tuple[str, ...]
SUPPRESS_HELP: str
SUPPRESS_USAGE: str
Expand Down
2 changes: 2 additions & 0 deletions stdlib/os/path.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ import sys

if sys.platform == "win32":
from ntpath import *
from ntpath import __all__ as __all__
else:
from posixpath import *
from posixpath import __all__ as __all__
2 changes: 2 additions & 0 deletions stdlib/pathlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ from typing_extensions import Literal
if sys.version_info >= (3, 9):
from types import GenericAlias

__all__ = ["PurePath", "PurePosixPath", "PureWindowsPath", "Path", "PosixPath", "WindowsPath"]

class PurePath(PathLike[str]):
parts: tuple[str, ...]
drive: str
Expand Down
2 changes: 2 additions & 0 deletions stdlib/pdb.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ from types import CodeType, FrameType, TracebackType
from typing import IO, Any, Callable, ClassVar, Iterable, Mapping, Sequence, TypeVar
from typing_extensions import ParamSpec

__all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace", "post_mortem", "help"]

_T = TypeVar("_T")
_P = ParamSpec("_P")

Expand Down
2 changes: 2 additions & 0 deletions stdlib/pickletools.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import IO, Any, Callable, Iterator, MutableMapping

__all__ = ["dis", "genops", "optimize"]

_Reader = Callable[[IO[bytes]], Any]
bytes_types: tuple[type[Any], ...]

Expand Down
2 changes: 2 additions & 0 deletions stdlib/pipes.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os

__all__ = ["Template"]

class Template:
def __init__(self) -> None: ...
def reset(self) -> None: ...
Expand Down
15 changes: 15 additions & 0 deletions stdlib/pkgutil.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ from _typeshed import SupportsRead
from importlib.abc import Loader, MetaPathFinder, PathEntryFinder
from typing import IO, Any, Callable, Iterable, Iterator, NamedTuple

__all__ = [
"get_importer",
"iter_importers",
"get_loader",
"find_loader",
"walk_packages",
"iter_modules",
"get_data",
"ImpImporter",
"ImpLoader",
"read_code",
"extend_path",
"ModuleInfo",
]

class ModuleInfo(NamedTuple):
module_finder: MetaPathFinder | PathEntryFinder
name: str
Expand Down
Loading