Skip to content

Commit d6ce3ab

Browse files
authored
Add __all__ to most modules beginning with 'n', 'o' and 'p' (#7345)
1 parent 09c945b commit d6ce3ab

20 files changed

+377
-2
lines changed

stdlib/netrc.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from _typeshed import StrOrBytesPath
22
from typing import Optional
33

4+
__all__ = ["netrc", "NetrcParseError"]
5+
46
class NetrcParseError(Exception):
57
filename: str | None
68
lineno: int | None

stdlib/nntplib.pyi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ from _typeshed import Self
66
from typing import IO, Any, Iterable, NamedTuple, Union
77
from typing_extensions import Literal
88

9+
__all__ = [
10+
"NNTP",
11+
"NNTPError",
12+
"NNTPReplyError",
13+
"NNTPTemporaryError",
14+
"NNTPPermanentError",
15+
"NNTPProtocolError",
16+
"NNTPDataError",
17+
"decode_header",
18+
"NNTP_SSL",
19+
]
20+
921
_File = Union[IO[bytes], bytes, str, None]
1022

1123
class NNTPError(Exception):

stdlib/ntpath.pyi

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,94 @@ from posixpath import (
4444
)
4545
from typing import AnyStr, overload
4646

47-
altsep: str
48-
if sys.version_info < (3, 7) and sys.platform == "win32":
47+
if sys.version_info >= (3, 7) or sys.platform != "win32":
48+
__all__ = [
49+
"normcase",
50+
"isabs",
51+
"join",
52+
"splitdrive",
53+
"split",
54+
"splitext",
55+
"basename",
56+
"dirname",
57+
"commonprefix",
58+
"getsize",
59+
"getmtime",
60+
"getatime",
61+
"getctime",
62+
"islink",
63+
"exists",
64+
"lexists",
65+
"isdir",
66+
"isfile",
67+
"ismount",
68+
"expanduser",
69+
"expandvars",
70+
"normpath",
71+
"abspath",
72+
"curdir",
73+
"pardir",
74+
"sep",
75+
"pathsep",
76+
"defpath",
77+
"altsep",
78+
"extsep",
79+
"devnull",
80+
"realpath",
81+
"supports_unicode_filenames",
82+
"relpath",
83+
"samefile",
84+
"sameopenfile",
85+
"samestat",
86+
"commonpath",
87+
]
88+
else:
89+
__all__ = [
90+
"normcase",
91+
"isabs",
92+
"join",
93+
"splitdrive",
94+
"split",
95+
"splitext",
96+
"basename",
97+
"dirname",
98+
"commonprefix",
99+
"getsize",
100+
"getmtime",
101+
"getatime",
102+
"getctime",
103+
"islink",
104+
"exists",
105+
"lexists",
106+
"isdir",
107+
"isfile",
108+
"ismount",
109+
"expanduser",
110+
"expandvars",
111+
"normpath",
112+
"abspath",
113+
"splitunc",
114+
"curdir",
115+
"pardir",
116+
"sep",
117+
"pathsep",
118+
"defpath",
119+
"altsep",
120+
"extsep",
121+
"devnull",
122+
"realpath",
123+
"supports_unicode_filenames",
124+
"relpath",
125+
"samefile",
126+
"sameopenfile",
127+
"samestat",
128+
"commonpath",
129+
]
130+
49131
def splitunc(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... # deprecated
50132

133+
altsep: str
134+
51135
# First parameter is not actually pos-only,
52136
# but must be defined as pos-only in the stub or cross-platform code doesn't type-check,
53137
# as the parameter name is different in posixpath.join()

stdlib/numbers.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from abc import ABCMeta, abstractmethod
55
from typing import Any, SupportsFloat, overload
66

7+
__all__ = ["Number", "Complex", "Real", "Rational", "Integral"]
8+
79
class Number(metaclass=ABCMeta):
810
@abstractmethod
911
def __hash__(self) -> int: ...

stdlib/operator.pyi

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,122 @@ import sys
22

33
from _operator import *
44

5+
if sys.version_info >= (3, 11):
6+
__all__ = [
7+
"abs",
8+
"add",
9+
"and_",
10+
"attrgetter",
11+
"call",
12+
"concat",
13+
"contains",
14+
"countOf",
15+
"delitem",
16+
"eq",
17+
"floordiv",
18+
"ge",
19+
"getitem",
20+
"gt",
21+
"iadd",
22+
"iand",
23+
"iconcat",
24+
"ifloordiv",
25+
"ilshift",
26+
"imatmul",
27+
"imod",
28+
"imul",
29+
"index",
30+
"indexOf",
31+
"inv",
32+
"invert",
33+
"ior",
34+
"ipow",
35+
"irshift",
36+
"is_",
37+
"is_not",
38+
"isub",
39+
"itemgetter",
40+
"itruediv",
41+
"ixor",
42+
"le",
43+
"length_hint",
44+
"lshift",
45+
"lt",
46+
"matmul",
47+
"methodcaller",
48+
"mod",
49+
"mul",
50+
"ne",
51+
"neg",
52+
"not_",
53+
"or_",
54+
"pos",
55+
"pow",
56+
"rshift",
57+
"setitem",
58+
"sub",
59+
"truediv",
60+
"truth",
61+
"xor",
62+
]
63+
else:
64+
__all__ = [
65+
"abs",
66+
"add",
67+
"and_",
68+
"attrgetter",
69+
"concat",
70+
"contains",
71+
"countOf",
72+
"delitem",
73+
"eq",
74+
"floordiv",
75+
"ge",
76+
"getitem",
77+
"gt",
78+
"iadd",
79+
"iand",
80+
"iconcat",
81+
"ifloordiv",
82+
"ilshift",
83+
"imatmul",
84+
"imod",
85+
"imul",
86+
"index",
87+
"indexOf",
88+
"inv",
89+
"invert",
90+
"ior",
91+
"ipow",
92+
"irshift",
93+
"is_",
94+
"is_not",
95+
"isub",
96+
"itemgetter",
97+
"itruediv",
98+
"ixor",
99+
"le",
100+
"length_hint",
101+
"lshift",
102+
"lt",
103+
"matmul",
104+
"methodcaller",
105+
"mod",
106+
"mul",
107+
"ne",
108+
"neg",
109+
"not_",
110+
"or_",
111+
"pos",
112+
"pow",
113+
"rshift",
114+
"setitem",
115+
"sub",
116+
"truediv",
117+
"truth",
118+
"xor",
119+
]
120+
5121
__lt__ = lt
6122
__le__ = le
7123
__eq__ = eq

stdlib/optparse.pyi

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
from abc import abstractmethod
22
from typing import IO, Any, AnyStr, Callable, Iterable, Mapping, Sequence, overload
33

4+
__all__ = [
5+
"Option",
6+
"make_option",
7+
"SUPPRESS_HELP",
8+
"SUPPRESS_USAGE",
9+
"Values",
10+
"OptionContainer",
11+
"OptionGroup",
12+
"OptionParser",
13+
"HelpFormatter",
14+
"IndentedHelpFormatter",
15+
"TitledHelpFormatter",
16+
"OptParseError",
17+
"OptionError",
18+
"OptionConflictError",
19+
"OptionValueError",
20+
"BadOptionError",
21+
"check_choice",
22+
]
23+
424
NO_DEFAULT: tuple[str, ...]
525
SUPPRESS_HELP: str
626
SUPPRESS_USAGE: str

stdlib/os/path.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ import sys
22

33
if sys.platform == "win32":
44
from ntpath import *
5+
from ntpath import __all__ as __all__
56
else:
67
from posixpath import *
8+
from posixpath import __all__ as __all__

stdlib/pathlib.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ from typing_extensions import Literal
1717
if sys.version_info >= (3, 9):
1818
from types import GenericAlias
1919

20+
__all__ = ["PurePath", "PurePosixPath", "PureWindowsPath", "Path", "PosixPath", "WindowsPath"]
21+
2022
class PurePath(PathLike[str]):
2123
parts: tuple[str, ...]
2224
drive: str

stdlib/pdb.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ from types import CodeType, FrameType, TracebackType
88
from typing import IO, Any, Callable, ClassVar, Iterable, Mapping, Sequence, TypeVar
99
from typing_extensions import ParamSpec
1010

11+
__all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace", "post_mortem", "help"]
12+
1113
_T = TypeVar("_T")
1214
_P = ParamSpec("_P")
1315

stdlib/pickletools.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from typing import IO, Any, Callable, Iterator, MutableMapping
22

3+
__all__ = ["dis", "genops", "optimize"]
4+
35
_Reader = Callable[[IO[bytes]], Any]
46
bytes_types: tuple[type[Any], ...]
57

stdlib/pipes.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import os
22

3+
__all__ = ["Template"]
4+
35
class Template:
46
def __init__(self) -> None: ...
57
def reset(self) -> None: ...

stdlib/pkgutil.pyi

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ from _typeshed import SupportsRead
33
from importlib.abc import Loader, MetaPathFinder, PathEntryFinder
44
from typing import IO, Any, Callable, Iterable, Iterator, NamedTuple
55

6+
__all__ = [
7+
"get_importer",
8+
"iter_importers",
9+
"get_loader",
10+
"find_loader",
11+
"walk_packages",
12+
"iter_modules",
13+
"get_data",
14+
"ImpImporter",
15+
"ImpLoader",
16+
"read_code",
17+
"extend_path",
18+
"ModuleInfo",
19+
]
20+
621
class ModuleInfo(NamedTuple):
722
module_finder: MetaPathFinder | PathEntryFinder
823
name: str

0 commit comments

Comments
 (0)