Skip to content

Fix various __all__-related errors and omissions #8031

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 8 commits into from
Jun 7, 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
10 changes: 10 additions & 0 deletions stdlib/_dummy_thread.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import sys
from collections.abc import Callable
from types import TracebackType
from typing import Any, NoReturn

__all__ = ["error", "start_new_thread", "exit", "get_ident", "allocate_lock", "interrupt_main", "LockType"]

if sys.version_info >= (3, 7):
__all__ += ["RLock"]

TIMEOUT_MAX: int
error = RuntimeError

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

if sys.version_info >= (3, 7):
class RLock(LockType):
def release(self) -> None: ... # type: ignore[override]

def interrupt_main() -> None: ...
29 changes: 29 additions & 0 deletions stdlib/collections/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,35 @@ else:

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

if sys.version_info < (3, 7):
__all__ += [
"Awaitable",
"Coroutine",
"AsyncIterable",
"AsyncIterator",
"AsyncGenerator",
"Hashable",
"Iterable",
"Iterator",
"Generator",
"Reversible",
"Sized",
"Container",
"Callable",
"Collection",
"Set",
"MutableSet",
"Mapping",
"MutableMapping",
"MappingView",
"KeysView",
"ItemsView",
"ValuesView",
"Sequence",
"MutableSequence",
"ByteString",
]

_S = TypeVar("_S")
_T = TypeVar("_T")
_T1 = TypeVar("_T1")
Expand Down
16 changes: 16 additions & 0 deletions stdlib/importlib/abc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWra
from typing import IO, Any, BinaryIO, NoReturn, Protocol, overload, runtime_checkable
from typing_extensions import Literal, TypeAlias

if sys.version_info >= (3, 11):
__all__ = [
"Loader",
"Finder",
"MetaPathFinder",
"PathEntryFinder",
"ResourceLoader",
"InspectLoader",
"ExecutionLoader",
"FileLoader",
"SourceLoader",
"ResourceReader",
"Traversable",
"TraversableResources",
]

_Path: TypeAlias = bytes | str

class Finder(metaclass=ABCMeta): ...
Expand Down
2 changes: 1 addition & 1 deletion stdlib/lib2to3/pgen2/tokenize.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ __all__ = [
"untokenize",
]

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

_Coord: TypeAlias = tuple[int, int]
Expand Down
3 changes: 3 additions & 0 deletions stdlib/locale.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ __all__ = [
"CHAR_MAX",
]

if sys.version_info >= (3, 11):
__all__ += ["getencoding"]

# This module defines a function "str()", which is why "str" can't be used
# as a type annotation or type alias.
from builtins import str as _str
Expand Down
35 changes: 35 additions & 0 deletions stdlib/macpath.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,41 @@ from posixpath import (
)
from typing import AnyStr, overload

__all__ = [
"normcase",
"isabs",
"join",
"splitdrive",
"split",
"splitext",
"basename",
"dirname",
"commonprefix",
"getsize",
"getmtime",
"getatime",
"getctime",
"islink",
"exists",
"lexists",
"isdir",
"isfile",
"expanduser",
"expandvars",
"normpath",
"abspath",
"curdir",
"pardir",
"sep",
"pathsep",
"defpath",
"altsep",
"extsep",
"devnull",
"realpath",
"supports_unicode_filenames",
]

altsep: str | None

@overload
Expand Down
2 changes: 2 additions & 0 deletions stdlib/macurl2path.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
__all__ = ["url2pathname", "pathname2url"]

def url2pathname(pathname: str) -> str: ...
def pathname2url(pathname: str) -> str: ...
def _pncomp2url(component: str | bytes) -> str: ...
2 changes: 1 addition & 1 deletion stdlib/ntpath.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ __all__ = [
"commonpath",
]

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

def splitunc(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... # deprecated
Expand Down
2 changes: 1 addition & 1 deletion stdlib/re.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ __all__ = [
"UNICODE",
]

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

if sys.version_info >= (3, 11):
Expand Down
2 changes: 1 addition & 1 deletion stdlib/types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ __all__ = [
"prepare_class",
"DynamicClassAttribute",
"coroutine",
"BuiltinMethodType",
]

if sys.version_info >= (3, 7):
__all__ += [
"BuiltinMethodType",
"ClassMethodDescriptorType",
"MethodDescriptorType",
"MethodWrapperType",
Expand Down
22 changes: 9 additions & 13 deletions stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@ __all__ = [
"AbstractSet",
"Any",
"AnyStr",
"AsyncContextManager",
"AsyncGenerator",
"AsyncIterable",
"AsyncIterator",
"Awaitable",
"ByteString",
"Callable",
"ChainMap",
"ClassVar",
"Collection",
"Container",
"ContextManager",
"Coroutine",
"Counter",
"DefaultDict",
"Deque",
Expand Down Expand Up @@ -69,19 +77,7 @@ if sys.version_info < (3, 7):
__all__ += ["GenericMeta"]

if sys.version_info >= (3, 7):
__all__ += [
"AsyncContextManager",
"AsyncGenerator",
"AsyncIterable",
"AsyncIterator",
"Awaitable",
"ChainMap",
"Collection",
"Coroutine",
"ForwardRef",
"NoReturn",
"OrderedDict",
]
__all__ += ["ForwardRef", "NoReturn", "OrderedDict"]

if sys.version_info >= (3, 8):
__all__ += [
Expand Down
1 change: 0 additions & 1 deletion tests/stubtest_allowlists/darwin-py36.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pwd.getpwnam
webbrowser.MacOSXOSAScript.__init__

# Exists at runtime, but missing from stubs
ntpath.splitunc
posix.stat_float_times
ssl.OP_ENABLE_MIDDLEBOX_COMPAT
ssl.Options.OP_ENABLE_MIDDLEBOX_COMPAT
Expand Down
1 change: 0 additions & 1 deletion tests/stubtest_allowlists/linux-py36.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ ctypes.wintypes
pwd.getpwnam

# Exists at runtime, but missing from stubs
ntpath.splitunc
posix.stat_float_times
ssl.OP_ENABLE_MIDDLEBOX_COMPAT
ssl.Options.OP_ENABLE_MIDDLEBOX_COMPAT
Expand Down
1 change: 0 additions & 1 deletion tests/stubtest_allowlists/py37.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ tempfile.SpooledTemporaryFile.seekable
tempfile.SpooledTemporaryFile.writable

# Exists at runtime, but missing from stubs
_dummy_thread.RLock
contextvars.ContextVar.__class_getitem__
datetime.datetime_CAPI
distutils.dist.DistributionMetadata.set_classifiers
Expand Down
1 change: 0 additions & 1 deletion tests/stubtest_allowlists/py38.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ tempfile.SpooledTemporaryFile.seekable
tempfile.SpooledTemporaryFile.writable

# Exists at runtime, but missing from stubs
_dummy_thread.RLock
contextvars.ContextVar.__class_getitem__
datetime.datetime_CAPI
distutils.dist.DistributionMetadata.set_classifiers
Expand Down