Skip to content

Commit e7a5b7a

Browse files
authored
Fix various __all__-related errors and omissions (#8031)
1 parent 591593c commit e7a5b7a

File tree

15 files changed

+108
-21
lines changed

15 files changed

+108
-21
lines changed

stdlib/_dummy_thread.pyi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
import sys
12
from collections.abc import Callable
23
from types import TracebackType
34
from typing import Any, NoReturn
45

6+
__all__ = ["error", "start_new_thread", "exit", "get_ident", "allocate_lock", "interrupt_main", "LockType"]
7+
8+
if sys.version_info >= (3, 7):
9+
__all__ += ["RLock"]
10+
511
TIMEOUT_MAX: int
612
error = RuntimeError
713

@@ -20,4 +26,8 @@ class LockType:
2026
def release(self) -> bool: ...
2127
def locked(self) -> bool: ...
2228

29+
if sys.version_info >= (3, 7):
30+
class RLock(LockType):
31+
def release(self) -> None: ... # type: ignore[override]
32+
2333
def interrupt_main() -> None: ...

stdlib/collections/__init__.pyi

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,35 @@ else:
1414

1515
__all__ = ["ChainMap", "Counter", "OrderedDict", "UserDict", "UserList", "UserString", "defaultdict", "deque", "namedtuple"]
1616

17+
if sys.version_info < (3, 7):
18+
__all__ += [
19+
"Awaitable",
20+
"Coroutine",
21+
"AsyncIterable",
22+
"AsyncIterator",
23+
"AsyncGenerator",
24+
"Hashable",
25+
"Iterable",
26+
"Iterator",
27+
"Generator",
28+
"Reversible",
29+
"Sized",
30+
"Container",
31+
"Callable",
32+
"Collection",
33+
"Set",
34+
"MutableSet",
35+
"Mapping",
36+
"MutableMapping",
37+
"MappingView",
38+
"KeysView",
39+
"ItemsView",
40+
"ValuesView",
41+
"Sequence",
42+
"MutableSequence",
43+
"ByteString",
44+
]
45+
1746
_S = TypeVar("_S")
1847
_T = TypeVar("_T")
1948
_T1 = TypeVar("_T1")

stdlib/importlib/abc.pyi

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@ from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWra
1616
from typing import IO, Any, BinaryIO, NoReturn, Protocol, overload, runtime_checkable
1717
from typing_extensions import Literal, TypeAlias
1818

19+
if sys.version_info >= (3, 11):
20+
__all__ = [
21+
"Loader",
22+
"Finder",
23+
"MetaPathFinder",
24+
"PathEntryFinder",
25+
"ResourceLoader",
26+
"InspectLoader",
27+
"ExecutionLoader",
28+
"FileLoader",
29+
"SourceLoader",
30+
"ResourceReader",
31+
"Traversable",
32+
"TraversableResources",
33+
]
34+
1935
_Path: TypeAlias = bytes | str
2036

2137
class Finder(metaclass=ABCMeta): ...

stdlib/lib2to3/pgen2/tokenize.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ __all__ = [
7474
"untokenize",
7575
]
7676

77-
if sys.version_info >= (3, 8):
77+
if sys.version_info >= (3, 7):
7878
__all__ += ["COLONEQUAL"]
7979

8080
_Coord: TypeAlias = tuple[int, int]

stdlib/locale.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ __all__ = [
2929
"CHAR_MAX",
3030
]
3131

32+
if sys.version_info >= (3, 11):
33+
__all__ += ["getencoding"]
34+
3235
# This module defines a function "str()", which is why "str" can't be used
3336
# as a type annotation or type alias.
3437
from builtins import str as _str

stdlib/macpath.pyi

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,41 @@ from posixpath import (
3434
)
3535
from typing import AnyStr, overload
3636

37+
__all__ = [
38+
"normcase",
39+
"isabs",
40+
"join",
41+
"splitdrive",
42+
"split",
43+
"splitext",
44+
"basename",
45+
"dirname",
46+
"commonprefix",
47+
"getsize",
48+
"getmtime",
49+
"getatime",
50+
"getctime",
51+
"islink",
52+
"exists",
53+
"lexists",
54+
"isdir",
55+
"isfile",
56+
"expanduser",
57+
"expandvars",
58+
"normpath",
59+
"abspath",
60+
"curdir",
61+
"pardir",
62+
"sep",
63+
"pathsep",
64+
"defpath",
65+
"altsep",
66+
"extsep",
67+
"devnull",
68+
"realpath",
69+
"supports_unicode_filenames",
70+
]
71+
3772
altsep: str | None
3873

3974
@overload

stdlib/macurl2path.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
__all__ = ["url2pathname", "pathname2url"]
2+
13
def url2pathname(pathname: str) -> str: ...
24
def pathname2url(pathname: str) -> str: ...
35
def _pncomp2url(component: str | bytes) -> str: ...

stdlib/ntpath.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ __all__ = [
8686
"commonpath",
8787
]
8888

89-
if sys.version_info < (3, 7) and sys.platform == "win32":
89+
if sys.version_info < (3, 7):
9090
__all__ += ["splitunc"]
9191

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

stdlib/re.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ __all__ = [
4343
"UNICODE",
4444
]
4545

46-
if sys.version_info >= (3, 8):
46+
if sys.version_info >= (3, 7):
4747
__all__ += ["Match", "Pattern"]
4848

4949
if sys.version_info >= (3, 11):

stdlib/types.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ __all__ = [
4040
"prepare_class",
4141
"DynamicClassAttribute",
4242
"coroutine",
43+
"BuiltinMethodType",
4344
]
4445

4546
if sys.version_info >= (3, 7):
4647
__all__ += [
47-
"BuiltinMethodType",
4848
"ClassMethodDescriptorType",
4949
"MethodDescriptorType",
5050
"MethodWrapperType",

0 commit comments

Comments
 (0)