Fix various __all__-related errors and omissions (#8031)

This commit is contained in:
Alex Waygood
2022-06-07 23:29:55 +01:00
committed by GitHub
parent 591593c85f
commit e7a5b7a762
15 changed files with 108 additions and 21 deletions

View File

@@ -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
@@ -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: ...

View File

@@ -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")

View File

@@ -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): ...

View File

@@ -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]

View File

@@ -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

View File

@@ -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

View File

@@ -1,3 +1,5 @@
__all__ = ["url2pathname", "pathname2url"]
def url2pathname(pathname: str) -> str: ...
def pathname2url(pathname: str) -> str: ...
def _pncomp2url(component: str | bytes) -> str: ...

View File

@@ -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

View File

@@ -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):

View File

@@ -40,11 +40,11 @@ __all__ = [
"prepare_class",
"DynamicClassAttribute",
"coroutine",
"BuiltinMethodType",
]
if sys.version_info >= (3, 7):
__all__ += [
"BuiltinMethodType",
"ClassMethodDescriptorType",
"MethodDescriptorType",
"MethodWrapperType",

View File

@@ -15,11 +15,19 @@ __all__ = [
"AbstractSet",
"Any",
"AnyStr",
"AsyncContextManager",
"AsyncGenerator",
"AsyncIterable",
"AsyncIterator",
"Awaitable",
"ByteString",
"Callable",
"ChainMap",
"ClassVar",
"Collection",
"Container",
"ContextManager",
"Coroutine",
"Counter",
"DefaultDict",
"Deque",
@@ -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__ += [

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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