From e88a182573ee0f6bf64ae1161977e4d05ccf25ba Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 7 Jun 2022 14:40:48 +0100 Subject: [PATCH] Simplify `__all__` definitions in modules beginning with 'a' to 'l' (#8026) --- stdlib/__future__.pyi | 40 ++--- stdlib/_dummy_threading.pyi | 74 +++------ stdlib/_pydecimal.pyi | 118 +++++--------- stdlib/argparse.pyi | 61 +++---- stdlib/base64.pyi | 65 +++----- stdlib/calendar.pyi | 88 ++++------ stdlib/cgi.pyi | 50 ++---- stdlib/contextlib.pyi | 76 +++------ stdlib/dataclasses.pyi | 46 ++---- stdlib/enum.pyi | 45 +++--- stdlib/functools.pyi | 65 +++----- stdlib/gettext.pyi | 83 +++------- stdlib/importlib/metadata/__init__.pyi | 41 ++--- stdlib/importlib/resources.pyi | 36 +---- stdlib/io.pyi | 64 +++----- stdlib/lib2to3/pgen2/tokenize.pyi | 214 +++++++++---------------- stdlib/logging/__init__.pyi | 136 ++++++---------- 17 files changed, 419 insertions(+), 883 deletions(-) diff --git a/stdlib/__future__.pyi b/stdlib/__future__.pyi index 1a465c3e2..52941a0c5 100644 --- a/stdlib/__future__.pyi +++ b/stdlib/__future__.pyi @@ -21,30 +21,18 @@ if sys.version_info >= (3, 7): all_feature_names: list[str] # undocumented +__all__ = [ + "all_feature_names", + "absolute_import", + "division", + "generators", + "nested_scopes", + "print_function", + "unicode_literals", + "with_statement", + "barry_as_FLUFL", + "generator_stop", +] + if sys.version_info >= (3, 7): - __all__ = [ - "all_feature_names", - "absolute_import", - "division", - "generators", - "nested_scopes", - "print_function", - "unicode_literals", - "with_statement", - "barry_as_FLUFL", - "generator_stop", - "annotations", - ] -else: - __all__ = [ - "all_feature_names", - "absolute_import", - "division", - "generators", - "nested_scopes", - "print_function", - "unicode_literals", - "with_statement", - "barry_as_FLUFL", - "generator_stop", - ] + __all__ += ["annotations"] diff --git a/stdlib/_dummy_threading.pyi b/stdlib/_dummy_threading.pyi index 2daceaedd..6f888b3dd 100644 --- a/stdlib/_dummy_threading.pyi +++ b/stdlib/_dummy_threading.pyi @@ -10,56 +10,32 @@ _TF: TypeAlias = Callable[[FrameType, str, Any], Callable[..., Any] | None] _PF: TypeAlias = Callable[[FrameType, str, Any], None] _T = TypeVar("_T") +__all__ = [ + "get_ident", + "active_count", + "Condition", + "current_thread", + "enumerate", + "main_thread", + "TIMEOUT_MAX", + "Event", + "Lock", + "RLock", + "Semaphore", + "BoundedSemaphore", + "Thread", + "Barrier", + "BrokenBarrierError", + "Timer", + "ThreadError", + "setprofile", + "settrace", + "local", + "stack_size", +] + if sys.version_info >= (3, 8): - __all__ = [ - "get_ident", - "active_count", - "Condition", - "current_thread", - "enumerate", - "main_thread", - "TIMEOUT_MAX", - "Event", - "Lock", - "RLock", - "Semaphore", - "BoundedSemaphore", - "Thread", - "Barrier", - "BrokenBarrierError", - "Timer", - "ThreadError", - "setprofile", - "settrace", - "local", - "stack_size", - "excepthook", - "ExceptHookArgs", - ] -else: - __all__ = [ - "get_ident", - "active_count", - "Condition", - "current_thread", - "enumerate", - "main_thread", - "TIMEOUT_MAX", - "Event", - "Lock", - "RLock", - "Semaphore", - "BoundedSemaphore", - "Thread", - "Barrier", - "BrokenBarrierError", - "Timer", - "ThreadError", - "setprofile", - "settrace", - "local", - "stack_size", - ] + __all__ += ["ExceptHookArgs", "excepthook"] def active_count() -> int: ... def current_thread() -> Thread: ... diff --git a/stdlib/_pydecimal.pyi b/stdlib/_pydecimal.pyi index 90dbef1dc..0d639bc16 100644 --- a/stdlib/_pydecimal.pyi +++ b/stdlib/_pydecimal.pyi @@ -4,82 +4,44 @@ import sys # However, in all likelihood, the differences are inconsequential from _decimal import * +__all__ = [ + "Decimal", + "Context", + "DecimalTuple", + "DefaultContext", + "BasicContext", + "ExtendedContext", + "DecimalException", + "Clamped", + "InvalidOperation", + "DivisionByZero", + "Inexact", + "Rounded", + "Subnormal", + "Overflow", + "Underflow", + "FloatOperation", + "DivisionImpossible", + "InvalidContext", + "ConversionSyntax", + "DivisionUndefined", + "ROUND_DOWN", + "ROUND_HALF_UP", + "ROUND_HALF_EVEN", + "ROUND_CEILING", + "ROUND_FLOOR", + "ROUND_UP", + "ROUND_HALF_DOWN", + "ROUND_05UP", + "setcontext", + "getcontext", + "localcontext", + "MAX_PREC", + "MAX_EMAX", + "MIN_EMIN", + "MIN_ETINY", + "HAVE_THREADS", +] + if sys.version_info >= (3, 7): - __all__ = [ - "Decimal", - "Context", - "DecimalTuple", - "DefaultContext", - "BasicContext", - "ExtendedContext", - "DecimalException", - "Clamped", - "InvalidOperation", - "DivisionByZero", - "Inexact", - "Rounded", - "Subnormal", - "Overflow", - "Underflow", - "FloatOperation", - "DivisionImpossible", - "InvalidContext", - "ConversionSyntax", - "DivisionUndefined", - "ROUND_DOWN", - "ROUND_HALF_UP", - "ROUND_HALF_EVEN", - "ROUND_CEILING", - "ROUND_FLOOR", - "ROUND_UP", - "ROUND_HALF_DOWN", - "ROUND_05UP", - "setcontext", - "getcontext", - "localcontext", - "MAX_PREC", - "MAX_EMAX", - "MIN_EMIN", - "MIN_ETINY", - "HAVE_THREADS", - "HAVE_CONTEXTVAR", - ] -else: - __all__ = [ - "Decimal", - "Context", - "DecimalTuple", - "DefaultContext", - "BasicContext", - "ExtendedContext", - "DecimalException", - "Clamped", - "InvalidOperation", - "DivisionByZero", - "Inexact", - "Rounded", - "Subnormal", - "Overflow", - "Underflow", - "FloatOperation", - "DivisionImpossible", - "InvalidContext", - "ConversionSyntax", - "DivisionUndefined", - "ROUND_DOWN", - "ROUND_HALF_UP", - "ROUND_HALF_EVEN", - "ROUND_CEILING", - "ROUND_FLOOR", - "ROUND_UP", - "ROUND_HALF_DOWN", - "ROUND_05UP", - "setcontext", - "getcontext", - "localcontext", - "MAX_PREC", - "MAX_EMAX", - "MIN_EMIN", - "MIN_ETINY", - "HAVE_THREADS", - ] + __all__ += ["HAVE_CONTEXTVAR"] diff --git a/stdlib/argparse.pyi b/stdlib/argparse.pyi index 4448817aa..4f6cb6720 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -3,47 +3,28 @@ from collections.abc import Callable, Generator, Iterable, Sequence from typing import IO, Any, Generic, NewType, NoReturn, Pattern, Protocol, TypeVar, overload from typing_extensions import Literal, TypeAlias +__all__ = [ + "ArgumentParser", + "ArgumentError", + "ArgumentTypeError", + "FileType", + "HelpFormatter", + "ArgumentDefaultsHelpFormatter", + "RawDescriptionHelpFormatter", + "RawTextHelpFormatter", + "MetavarTypeHelpFormatter", + "Namespace", + "Action", + "ONE_OR_MORE", + "OPTIONAL", + "PARSER", + "REMAINDER", + "SUPPRESS", + "ZERO_OR_MORE", +] + if sys.version_info >= (3, 9): - __all__ = [ - "ArgumentParser", - "ArgumentError", - "ArgumentTypeError", - "BooleanOptionalAction", - "FileType", - "HelpFormatter", - "ArgumentDefaultsHelpFormatter", - "RawDescriptionHelpFormatter", - "RawTextHelpFormatter", - "MetavarTypeHelpFormatter", - "Namespace", - "Action", - "ONE_OR_MORE", - "OPTIONAL", - "PARSER", - "REMAINDER", - "SUPPRESS", - "ZERO_OR_MORE", - ] -else: - __all__ = [ - "ArgumentParser", - "ArgumentError", - "ArgumentTypeError", - "FileType", - "HelpFormatter", - "ArgumentDefaultsHelpFormatter", - "RawDescriptionHelpFormatter", - "RawTextHelpFormatter", - "MetavarTypeHelpFormatter", - "Namespace", - "Action", - "ONE_OR_MORE", - "OPTIONAL", - "PARSER", - "REMAINDER", - "SUPPRESS", - "ZERO_OR_MORE", - ] + __all__ += ["BooleanOptionalAction"] _T = TypeVar("_T") _ActionT = TypeVar("_ActionT", bound=Action) diff --git a/stdlib/base64.pyi b/stdlib/base64.pyi index ceed7d018..c2ec85cac 100644 --- a/stdlib/base64.pyi +++ b/stdlib/base64.pyi @@ -2,50 +2,29 @@ import sys from _typeshed import ReadableBuffer from typing import IO +__all__ = [ + "encode", + "decode", + "encodebytes", + "decodebytes", + "b64encode", + "b64decode", + "b32encode", + "b32decode", + "b16encode", + "b16decode", + "b85encode", + "b85decode", + "a85encode", + "a85decode", + "standard_b64encode", + "standard_b64decode", + "urlsafe_b64encode", + "urlsafe_b64decode", +] + if sys.version_info >= (3, 10): - __all__ = [ - "encode", - "decode", - "encodebytes", - "decodebytes", - "b64encode", - "b64decode", - "b32encode", - "b32decode", - "b32hexencode", - "b32hexdecode", - "b16encode", - "b16decode", - "b85encode", - "b85decode", - "a85encode", - "a85decode", - "standard_b64encode", - "standard_b64decode", - "urlsafe_b64encode", - "urlsafe_b64decode", - ] -else: - __all__ = [ - "encode", - "decode", - "encodebytes", - "decodebytes", - "b64encode", - "b64decode", - "b32encode", - "b32decode", - "b16encode", - "b16decode", - "b85encode", - "b85decode", - "a85encode", - "a85decode", - "standard_b64encode", - "standard_b64decode", - "urlsafe_b64encode", - "urlsafe_b64decode", - ] + __all__ += ["b32hexencode", "b32hexdecode"] def b64encode(s: ReadableBuffer, altchars: ReadableBuffer | None = ...) -> bytes: ... def b64decode(s: str | ReadableBuffer, altchars: ReadableBuffer | None = ..., validate: bool = ...) -> bytes: ... diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index c7e0a6b46..00b7054ba 100644 --- a/stdlib/calendar.pyi +++ b/stdlib/calendar.pyi @@ -4,67 +4,35 @@ from collections.abc import Iterable, Sequence from time import struct_time from typing_extensions import Literal, TypeAlias +__all__ = [ + "IllegalMonthError", + "IllegalWeekdayError", + "setfirstweekday", + "firstweekday", + "isleap", + "leapdays", + "weekday", + "monthrange", + "monthcalendar", + "prmonth", + "month", + "prcal", + "calendar", + "timegm", + "month_name", + "month_abbr", + "day_name", + "day_abbr", + "Calendar", + "TextCalendar", + "HTMLCalendar", + "LocaleTextCalendar", + "LocaleHTMLCalendar", + "weekheader", +] + if sys.version_info >= (3, 10): - __all__ = [ - "IllegalMonthError", - "IllegalWeekdayError", - "setfirstweekday", - "firstweekday", - "isleap", - "leapdays", - "weekday", - "monthrange", - "monthcalendar", - "prmonth", - "month", - "prcal", - "calendar", - "timegm", - "month_name", - "month_abbr", - "day_name", - "day_abbr", - "Calendar", - "TextCalendar", - "HTMLCalendar", - "LocaleTextCalendar", - "LocaleHTMLCalendar", - "weekheader", - "FRIDAY", - "MONDAY", - "SATURDAY", - "SUNDAY", - "THURSDAY", - "TUESDAY", - "WEDNESDAY", - ] -else: - __all__ = [ - "IllegalMonthError", - "IllegalWeekdayError", - "setfirstweekday", - "firstweekday", - "isleap", - "leapdays", - "weekday", - "monthrange", - "monthcalendar", - "prmonth", - "month", - "prcal", - "calendar", - "timegm", - "month_name", - "month_abbr", - "day_name", - "day_abbr", - "Calendar", - "TextCalendar", - "HTMLCalendar", - "LocaleTextCalendar", - "LocaleHTMLCalendar", - "weekheader", - ] + __all__ += ["FRIDAY", "MONDAY", "SATURDAY", "SUNDAY", "THURSDAY", "TUESDAY", "WEDNESDAY"] _LocaleType: TypeAlias = tuple[str | None, str | None] diff --git a/stdlib/cgi.pyi b/stdlib/cgi.pyi index 5e7bebc2a..59c0a2706 100644 --- a/stdlib/cgi.pyi +++ b/stdlib/cgi.pyi @@ -5,39 +5,23 @@ from collections.abc import Iterable, Iterator, Mapping from types import TracebackType from typing import IO, Any, Protocol -if sys.version_info >= (3, 8): - __all__ = [ - "MiniFieldStorage", - "FieldStorage", - "parse", - "parse_multipart", - "parse_header", - "test", - "print_exception", - "print_environ", - "print_form", - "print_directory", - "print_arguments", - "print_environ_usage", - ] -else: - __all__ = [ - "MiniFieldStorage", - "FieldStorage", - "parse", - "parse_qs", - "parse_qsl", - "parse_multipart", - "parse_header", - "test", - "print_exception", - "print_environ", - "print_form", - "print_directory", - "print_arguments", - "print_environ_usage", - "escape", - ] +__all__ = [ + "MiniFieldStorage", + "FieldStorage", + "parse", + "parse_multipart", + "parse_header", + "test", + "print_exception", + "print_environ", + "print_form", + "print_directory", + "print_arguments", + "print_environ_usage", +] + +if sys.version_info < (3, 8): + __all__ += ["parse_qs", "parse_qsl", "escape"] def parse( fp: IO[Any] | None = ..., diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index 54a47e28a..81213b954 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -5,65 +5,25 @@ from types import TracebackType from typing import IO, Any, ContextManager, Generic, Protocol, TypeVar, overload # noqa: Y027 from typing_extensions import ParamSpec, TypeAlias +__all__ = [ + "contextmanager", + "closing", + "AbstractContextManager", + "ContextDecorator", + "ExitStack", + "redirect_stdout", + "redirect_stderr", + "suppress", +] + +if sys.version_info >= (3, 7): + __all__ += ["AbstractAsyncContextManager", "AsyncExitStack", "asynccontextmanager", "nullcontext"] + +if sys.version_info >= (3, 10): + __all__ += ["aclosing"] + if sys.version_info >= (3, 11): - __all__ = [ - "asynccontextmanager", - "contextmanager", - "closing", - "nullcontext", - "AbstractContextManager", - "AbstractAsyncContextManager", - "AsyncExitStack", - "ContextDecorator", - "ExitStack", - "redirect_stdout", - "redirect_stderr", - "suppress", - "aclosing", - "chdir", - ] -elif sys.version_info >= (3, 10): - __all__ = [ - "asynccontextmanager", - "contextmanager", - "closing", - "nullcontext", - "AbstractContextManager", - "AbstractAsyncContextManager", - "AsyncExitStack", - "ContextDecorator", - "ExitStack", - "redirect_stdout", - "redirect_stderr", - "suppress", - "aclosing", - ] -elif sys.version_info >= (3, 7): - __all__ = [ - "asynccontextmanager", - "contextmanager", - "closing", - "nullcontext", - "AbstractContextManager", - "AbstractAsyncContextManager", - "AsyncExitStack", - "ContextDecorator", - "ExitStack", - "redirect_stdout", - "redirect_stderr", - "suppress", - ] -else: - __all__ = [ - "contextmanager", - "closing", - "AbstractContextManager", - "ContextDecorator", - "ExitStack", - "redirect_stdout", - "redirect_stderr", - "suppress", - ] + __all__ += ["chdir"] AbstractContextManager = ContextManager if sys.version_info >= (3, 7): diff --git a/stdlib/dataclasses.pyi b/stdlib/dataclasses.pyi index 013276479..04ae771fc 100644 --- a/stdlib/dataclasses.pyi +++ b/stdlib/dataclasses.pyi @@ -12,37 +12,23 @@ if sys.version_info >= (3, 9): _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) +__all__ = [ + "dataclass", + "field", + "Field", + "FrozenInstanceError", + "InitVar", + "MISSING", + "fields", + "asdict", + "astuple", + "make_dataclass", + "replace", + "is_dataclass", +] + if sys.version_info >= (3, 10): - __all__ = [ - "dataclass", - "field", - "Field", - "FrozenInstanceError", - "InitVar", - "KW_ONLY", - "MISSING", - "fields", - "asdict", - "astuple", - "make_dataclass", - "replace", - "is_dataclass", - ] -else: - __all__ = [ - "dataclass", - "field", - "Field", - "FrozenInstanceError", - "InitVar", - "MISSING", - "fields", - "asdict", - "astuple", - "make_dataclass", - "replace", - "is_dataclass", - ] + __all__ += ["KW_ONLY"] # define _MISSING_TYPE as an enum within the type stubs, # even though that is not really its type at runtime diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index 37d90443e..6063dc47b 100644 --- a/stdlib/enum.pyi +++ b/stdlib/enum.pyi @@ -7,38 +7,31 @@ from collections.abc import Iterable, Iterator, Mapping from typing import Any, Generic, TypeVar, overload from typing_extensions import Literal, TypeAlias +__all__ = ["EnumMeta", "Enum", "IntEnum", "Flag", "IntFlag", "auto", "unique"] + if sys.version_info >= (3, 11): - __all__ = [ + __all__ += [ + "CONFORM", + "CONTINUOUS", + "EJECT", + "EnumCheck", "EnumType", - "EnumMeta", - "Enum", - "IntEnum", - "StrEnum", - "Flag", - "IntFlag", + "FlagBoundary", + "KEEP", + "NAMED_FLAGS", "ReprEnum", - "auto", - "unique", - "property", - "verify", + "STRICT", + "StrEnum", + "UNIQUE", + "global_enum", + "global_enum_repr", + "global_flag_repr", + "global_str", "member", "nonmember", - "FlagBoundary", - "STRICT", - "CONFORM", - "EJECT", - "KEEP", - "global_flag_repr", - "global_enum_repr", - "global_str", - "global_enum", - "EnumCheck", - "CONTINUOUS", - "NAMED_FLAGS", - "UNIQUE", + "property", + "verify", ] -else: - __all__ = ["EnumMeta", "Enum", "IntEnum", "Flag", "IntFlag", "auto", "unique"] _EnumMemberT = TypeVar("_EnumMemberT") _EnumerationT = TypeVar("_EnumerationT", bound=type[Enum]) diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index 44feeed63..acc45cd42 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -8,52 +8,25 @@ from typing_extensions import Literal, TypeAlias, final if sys.version_info >= (3, 9): from types import GenericAlias - __all__ = [ - "update_wrapper", - "wraps", - "WRAPPER_ASSIGNMENTS", - "WRAPPER_UPDATES", - "total_ordering", - "cache", - "cmp_to_key", - "lru_cache", - "reduce", - "partial", - "partialmethod", - "singledispatch", - "singledispatchmethod", - "cached_property", - ] -elif sys.version_info >= (3, 8): - __all__ = [ - "update_wrapper", - "wraps", - "WRAPPER_ASSIGNMENTS", - "WRAPPER_UPDATES", - "total_ordering", - "cmp_to_key", - "lru_cache", - "reduce", - "partial", - "partialmethod", - "singledispatch", - "singledispatchmethod", - "cached_property", - ] -else: - __all__ = [ - "update_wrapper", - "wraps", - "WRAPPER_ASSIGNMENTS", - "WRAPPER_UPDATES", - "total_ordering", - "cmp_to_key", - "lru_cache", - "reduce", - "partial", - "partialmethod", - "singledispatch", - ] +__all__ = [ + "update_wrapper", + "wraps", + "WRAPPER_ASSIGNMENTS", + "WRAPPER_UPDATES", + "total_ordering", + "cmp_to_key", + "lru_cache", + "reduce", + "partial", + "partialmethod", + "singledispatch", +] + +if sys.version_info >= (3, 8): + __all__ += ["cached_property", "singledispatchmethod"] + +if sys.version_info >= (3, 9): + __all__ += ["cache"] _AnyCallable: TypeAlias = Callable[..., Any] diff --git a/stdlib/gettext.pyi b/stdlib/gettext.pyi index beb9318f9..3c07abeb2 100644 --- a/stdlib/gettext.pyi +++ b/stdlib/gettext.pyi @@ -5,69 +5,26 @@ from collections.abc import Callable, Container, Iterable, Sequence from typing import Any, Protocol, TypeVar, overload from typing_extensions import Final, Literal -if sys.version_info >= (3, 11): - __all__ = [ - "NullTranslations", - "GNUTranslations", - "Catalog", - "bindtextdomain", - "find", - "translation", - "install", - "textdomain", - "dgettext", - "dngettext", - "gettext", - "ngettext", - "pgettext", - "dpgettext", - "npgettext", - "dnpgettext", - ] -elif sys.version_info >= (3, 8): - __all__ = [ - "NullTranslations", - "GNUTranslations", - "Catalog", - "find", - "translation", - "install", - "textdomain", - "bindtextdomain", - "bind_textdomain_codeset", - "dgettext", - "dngettext", - "gettext", - "lgettext", - "ldgettext", - "ldngettext", - "lngettext", - "ngettext", - "pgettext", - "dpgettext", - "npgettext", - "dnpgettext", - ] -else: - __all__ = [ - "NullTranslations", - "GNUTranslations", - "Catalog", - "find", - "translation", - "install", - "textdomain", - "bindtextdomain", - "bind_textdomain_codeset", - "dgettext", - "dngettext", - "gettext", - "lgettext", - "ldgettext", - "ldngettext", - "lngettext", - "ngettext", - ] +__all__ = [ + "NullTranslations", + "GNUTranslations", + "Catalog", + "find", + "translation", + "install", + "textdomain", + "bindtextdomain", + "dgettext", + "dngettext", + "gettext", + "ngettext", +] + +if sys.version_info < (3, 11): + __all__ += ["bind_textdomain_codeset", "ldgettext", "ldngettext", "lgettext", "lngettext"] + +if sys.version_info >= (3, 8): + __all__ += ["dnpgettext", "dpgettext", "npgettext", "pgettext"] class _TranslationsReader(Protocol): def read(self) -> bytes: ... diff --git a/stdlib/importlib/metadata/__init__.pyi b/stdlib/importlib/metadata/__init__.pyi index 1f32f0770..6466ce0a2 100644 --- a/stdlib/importlib/metadata/__init__.pyi +++ b/stdlib/importlib/metadata/__init__.pyi @@ -9,34 +9,21 @@ from os import PathLike from pathlib import Path from typing import Any, ClassVar, NamedTuple, Pattern, overload +__all__ = [ + "Distribution", + "DistributionFinder", + "PackageNotFoundError", + "distribution", + "distributions", + "entry_points", + "files", + "metadata", + "requires", + "version", +] + if sys.version_info >= (3, 10): - __all__ = [ - "Distribution", - "DistributionFinder", - "PackageMetadata", - "PackageNotFoundError", - "distribution", - "distributions", - "entry_points", - "files", - "metadata", - "packages_distributions", - "requires", - "version", - ] -else: - __all__ = [ - "Distribution", - "DistributionFinder", - "PackageNotFoundError", - "distribution", - "distributions", - "entry_points", - "files", - "metadata", - "requires", - "version", - ] + __all__ += ["PackageMetadata", "packages_distributions"] if sys.version_info >= (3, 10): from importlib.metadata._meta import PackageMetadata as PackageMetadata diff --git a/stdlib/importlib/resources.pyi b/stdlib/importlib/resources.pyi index 439e571c3..28ca107f4 100644 --- a/stdlib/importlib/resources.pyi +++ b/stdlib/importlib/resources.pyi @@ -7,37 +7,13 @@ from types import ModuleType from typing import Any, BinaryIO, TextIO from typing_extensions import TypeAlias +__all__ = ["Package", "Resource", "contents", "is_resource", "open_binary", "open_text", "path", "read_binary", "read_text"] + +if sys.version_info >= (3, 9): + __all__ += ["as_file", "files"] + if sys.version_info >= (3, 10): - __all__ = [ - "Package", - "Resource", - "ResourceReader", - "as_file", - "contents", - "files", - "is_resource", - "open_binary", - "open_text", - "path", - "read_binary", - "read_text", - ] -elif sys.version_info >= (3, 9): - __all__ = [ - "Package", - "Resource", - "as_file", - "contents", - "files", - "is_resource", - "open_binary", - "open_text", - "path", - "read_binary", - "read_text", - ] -else: - __all__ = ["Package", "Resource", "contents", "is_resource", "open_binary", "open_text", "path", "read_binary", "read_text"] + __all__ += ["ResourceReader"] Package: TypeAlias = str | ModuleType diff --git a/stdlib/io.pyi b/stdlib/io.pyi index 327fd0d94..0670b65fe 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -8,49 +8,29 @@ from types import TracebackType from typing import IO, Any, BinaryIO, TextIO from typing_extensions import Literal +__all__ = [ + "BlockingIOError", + "open", + "IOBase", + "RawIOBase", + "FileIO", + "BytesIO", + "StringIO", + "BufferedIOBase", + "BufferedReader", + "BufferedWriter", + "BufferedRWPair", + "BufferedRandom", + "TextIOBase", + "TextIOWrapper", + "UnsupportedOperation", + "SEEK_SET", + "SEEK_CUR", + "SEEK_END", +] + if sys.version_info >= (3, 8): - __all__ = [ - "BlockingIOError", - "open", - "open_code", - "IOBase", - "RawIOBase", - "FileIO", - "BytesIO", - "StringIO", - "BufferedIOBase", - "BufferedReader", - "BufferedWriter", - "BufferedRWPair", - "BufferedRandom", - "TextIOBase", - "TextIOWrapper", - "UnsupportedOperation", - "SEEK_SET", - "SEEK_CUR", - "SEEK_END", - ] -else: - __all__ = [ - "BlockingIOError", - "open", - "IOBase", - "RawIOBase", - "FileIO", - "BytesIO", - "StringIO", - "BufferedIOBase", - "BufferedReader", - "BufferedWriter", - "BufferedRWPair", - "BufferedRandom", - "TextIOBase", - "TextIOWrapper", - "UnsupportedOperation", - "SEEK_SET", - "SEEK_CUR", - "SEEK_END", - ] + __all__ += ["open_code"] DEFAULT_BUFFER_SIZE: Literal[8192] diff --git a/stdlib/lib2to3/pgen2/tokenize.pyi b/stdlib/lib2to3/pgen2/tokenize.pyi index a998ad5fe..b5fd13e49 100644 --- a/stdlib/lib2to3/pgen2/tokenize.pyi +++ b/stdlib/lib2to3/pgen2/tokenize.pyi @@ -3,149 +3,79 @@ from collections.abc import Callable, Iterable, Iterator from lib2to3.pgen2.token import * from typing_extensions import TypeAlias +__all__ = [ + "AMPER", + "AMPEREQUAL", + "ASYNC", + "AT", + "ATEQUAL", + "AWAIT", + "BACKQUOTE", + "CIRCUMFLEX", + "CIRCUMFLEXEQUAL", + "COLON", + "COMMA", + "COMMENT", + "DEDENT", + "DOT", + "DOUBLESLASH", + "DOUBLESLASHEQUAL", + "DOUBLESTAR", + "DOUBLESTAREQUAL", + "ENDMARKER", + "EQEQUAL", + "EQUAL", + "ERRORTOKEN", + "GREATER", + "GREATEREQUAL", + "INDENT", + "ISEOF", + "ISNONTERMINAL", + "ISTERMINAL", + "LBRACE", + "LEFTSHIFT", + "LEFTSHIFTEQUAL", + "LESS", + "LESSEQUAL", + "LPAR", + "LSQB", + "MINEQUAL", + "MINUS", + "NAME", + "NEWLINE", + "NL", + "NOTEQUAL", + "NT_OFFSET", + "NUMBER", + "N_TOKENS", + "OP", + "PERCENT", + "PERCENTEQUAL", + "PLUS", + "PLUSEQUAL", + "RARROW", + "RBRACE", + "RIGHTSHIFT", + "RIGHTSHIFTEQUAL", + "RPAR", + "RSQB", + "SEMI", + "SLASH", + "SLASHEQUAL", + "STAR", + "STAREQUAL", + "STRING", + "TILDE", + "VBAR", + "VBAREQUAL", + "tok_name", + "tokenize", + "generate_tokens", + "untokenize", +] + if sys.version_info >= (3, 8): - __all__ = [ - "AMPER", - "AMPEREQUAL", - "ASYNC", - "AT", - "ATEQUAL", - "AWAIT", - "BACKQUOTE", - "CIRCUMFLEX", - "CIRCUMFLEXEQUAL", - "COLON", - "COLONEQUAL", - "COMMA", - "COMMENT", - "DEDENT", - "DOT", - "DOUBLESLASH", - "DOUBLESLASHEQUAL", - "DOUBLESTAR", - "DOUBLESTAREQUAL", - "ENDMARKER", - "EQEQUAL", - "EQUAL", - "ERRORTOKEN", - "GREATER", - "GREATEREQUAL", - "INDENT", - "ISEOF", - "ISNONTERMINAL", - "ISTERMINAL", - "LBRACE", - "LEFTSHIFT", - "LEFTSHIFTEQUAL", - "LESS", - "LESSEQUAL", - "LPAR", - "LSQB", - "MINEQUAL", - "MINUS", - "NAME", - "NEWLINE", - "NL", - "NOTEQUAL", - "NT_OFFSET", - "NUMBER", - "N_TOKENS", - "OP", - "PERCENT", - "PERCENTEQUAL", - "PLUS", - "PLUSEQUAL", - "RARROW", - "RBRACE", - "RIGHTSHIFT", - "RIGHTSHIFTEQUAL", - "RPAR", - "RSQB", - "SEMI", - "SLASH", - "SLASHEQUAL", - "STAR", - "STAREQUAL", - "STRING", - "TILDE", - "VBAR", - "VBAREQUAL", - "tok_name", - "tokenize", - "generate_tokens", - "untokenize", - ] -else: - __all__ = [ - "AMPER", - "AMPEREQUAL", - "ASYNC", - "AT", - "ATEQUAL", - "AWAIT", - "BACKQUOTE", - "CIRCUMFLEX", - "CIRCUMFLEXEQUAL", - "COLON", - "COMMA", - "COMMENT", - "DEDENT", - "DOT", - "DOUBLESLASH", - "DOUBLESLASHEQUAL", - "DOUBLESTAR", - "DOUBLESTAREQUAL", - "ENDMARKER", - "EQEQUAL", - "EQUAL", - "ERRORTOKEN", - "GREATER", - "GREATEREQUAL", - "INDENT", - "ISEOF", - "ISNONTERMINAL", - "ISTERMINAL", - "LBRACE", - "LEFTSHIFT", - "LEFTSHIFTEQUAL", - "LESS", - "LESSEQUAL", - "LPAR", - "LSQB", - "MINEQUAL", - "MINUS", - "NAME", - "NEWLINE", - "NL", - "NOTEQUAL", - "NT_OFFSET", - "NUMBER", - "N_TOKENS", - "OP", - "PERCENT", - "PERCENTEQUAL", - "PLUS", - "PLUSEQUAL", - "RARROW", - "RBRACE", - "RIGHTSHIFT", - "RIGHTSHIFTEQUAL", - "RPAR", - "RSQB", - "SEMI", - "SLASH", - "SLASHEQUAL", - "STAR", - "STAREQUAL", - "STRING", - "TILDE", - "VBAR", - "VBAREQUAL", - "tok_name", - "tokenize", - "generate_tokens", - "untokenize", - ] + __all__ += ["COLONEQUAL"] _Coord: TypeAlias = tuple[int, int] _TokenEater: TypeAlias = Callable[[int, str, _Coord, _Coord, str], None] diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index 0f45a9687..8ed2f0b62 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -12,97 +12,53 @@ from typing_extensions import Literal, TypeAlias if sys.version_info >= (3, 11): from types import GenericAlias +__all__ = [ + "BASIC_FORMAT", + "BufferingFormatter", + "CRITICAL", + "DEBUG", + "ERROR", + "FATAL", + "FileHandler", + "Filter", + "Formatter", + "Handler", + "INFO", + "LogRecord", + "Logger", + "LoggerAdapter", + "NOTSET", + "NullHandler", + "StreamHandler", + "WARN", + "WARNING", + "addLevelName", + "basicConfig", + "captureWarnings", + "critical", + "debug", + "disable", + "error", + "exception", + "fatal", + "getLevelName", + "getLogger", + "getLoggerClass", + "info", + "log", + "makeLogRecord", + "setLoggerClass", + "shutdown", + "warn", + "warning", + "getLogRecordFactory", + "setLogRecordFactory", + "lastResort", + "raiseExceptions", +] + if sys.version_info >= (3, 11): - __all__ = [ - "BASIC_FORMAT", - "BufferingFormatter", - "CRITICAL", - "DEBUG", - "ERROR", - "FATAL", - "FileHandler", - "Filter", - "Formatter", - "Handler", - "INFO", - "LogRecord", - "Logger", - "LoggerAdapter", - "NOTSET", - "NullHandler", - "StreamHandler", - "WARN", - "WARNING", - "addLevelName", - "basicConfig", - "captureWarnings", - "critical", - "debug", - "disable", - "error", - "exception", - "fatal", - "getLevelName", - "getLogger", - "getLoggerClass", - "info", - "log", - "makeLogRecord", - "setLoggerClass", - "shutdown", - "warn", - "warning", - "getLogRecordFactory", - "setLogRecordFactory", - "lastResort", - "raiseExceptions", - "getLevelNamesMapping", - ] -else: - __all__ = [ - "BASIC_FORMAT", - "BufferingFormatter", - "CRITICAL", - "DEBUG", - "ERROR", - "FATAL", - "FileHandler", - "Filter", - "Formatter", - "Handler", - "INFO", - "LogRecord", - "Logger", - "LoggerAdapter", - "NOTSET", - "NullHandler", - "StreamHandler", - "WARN", - "WARNING", - "addLevelName", - "basicConfig", - "captureWarnings", - "critical", - "debug", - "disable", - "error", - "exception", - "fatal", - "getLevelName", - "getLogger", - "getLoggerClass", - "info", - "log", - "makeLogRecord", - "setLoggerClass", - "shutdown", - "warn", - "warning", - "getLogRecordFactory", - "setLogRecordFactory", - "lastResort", - "raiseExceptions", - ] + __all__ += ["getLevelNamesMapping"] _SysExcInfoType: TypeAlias = Union[tuple[type[BaseException], BaseException, TracebackType | None], tuple[None, None, None]] _ExcInfoType: TypeAlias = None | bool | _SysExcInfoType | BaseException