Skip to content

Fix various __all__ bugs and omissions #7618

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 2 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
82 changes: 82 additions & 0 deletions stdlib/_pydecimal.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,85 @@
import sys

# This is a slight lie, the implementations aren't exactly identical
# However, in all likelihood, the differences are inconsequential
from decimal import *

if sys.version_info >= (3, 7):
__all__ = [
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprisingly, _pydecimal appears to have __all__ even though decimal doesn't. ¯\_(ツ)_/¯

"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",
]
87 changes: 61 additions & 26 deletions stdlib/calendar.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,67 @@ from collections.abc import Iterable, Sequence
from time import struct_time
from typing_extensions import Literal

__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",
]

_LocaleType = tuple[str | None, str | None]

Expand Down
6 changes: 1 addition & 5 deletions stdlib/poplib.pyi
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import socket
import ssl
import sys
from typing import Any, BinaryIO, NoReturn, Pattern, overload
from typing_extensions import Literal

if sys.version_info >= (3, 10):
__all__ = ["POP3", "error_proto", "POP3_SSL"]
else:
__all__ = ["POP3", "error_proto"]
__all__ = ["POP3", "error_proto", "POP3_SSL"]

_LongResp = tuple[bytes, list[bytes], int]

Expand Down
2 changes: 2 additions & 0 deletions stdlib/tty.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import sys
from typing import IO

if sys.platform != "win32":
__all__ = ["setraw", "setcbreak"]

_FD = int | IO[str]

# XXX: Undocumented integer constants
Expand Down
67 changes: 58 additions & 9 deletions stdlib/typing_extensions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,56 @@ from typing import ( # noqa: Y022,Y027
overload as overload,
)

__all__ = [
"ClassVar",
"Concatenate",
"Final",
"LiteralString",
"ParamSpec",
"Self",
"Type",
"TypeVarTuple",
"Unpack",
"Awaitable",
"AsyncIterator",
"AsyncIterable",
"Coroutine",
"AsyncGenerator",
"AsyncContextManager",
"ChainMap",
"ContextManager",
"Counter",
"Deque",
"DefaultDict",
"OrderedDict",
"TypedDict",
"SupportsIndex",
"Annotated",
"assert_never",
"dataclass_transform",
"final",
"IntVar",
"is_typeddict",
"Literal",
"NewType",
"overload",
"Protocol",
"reveal_type",
"runtime",
"runtime_checkable",
"Text",
"TypeAlias",
"TypeGuard",
"TYPE_CHECKING",
"Never",
"NoReturn",
"Required",
"NotRequired",
"get_args",
"get_origin",
"get_type_hints",
]

_T = TypeVar("_T")
_F = TypeVar("_F", bound=Callable[..., Any])
_TC = TypeVar("_TC", bound=Type[object])
Expand Down Expand Up @@ -82,15 +132,14 @@ TypedDict: object

OrderedDict = _Alias()

if sys.version_info >= (3, 7):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically we shouldn't do this because the change hasn't been released yet, but I don't want to have to duplicate __all__ here.

def get_type_hints(
obj: Callable[..., Any],
globalns: dict[str, Any] | None = ...,
localns: dict[str, Any] | None = ...,
include_extras: bool = ...,
) -> dict[str, Any]: ...
def get_args(tp: Any) -> tuple[Any, ...]: ...
def get_origin(tp: Any) -> Any | None: ...
def get_type_hints(
obj: Callable[..., Any],
globalns: dict[str, Any] | None = ...,
localns: dict[str, Any] | None = ...,
include_extras: bool = ...,
) -> dict[str, Any]: ...
def get_args(tp: Any) -> tuple[Any, ...]: ...
def get_origin(tp: Any) -> Any | None: ...

Annotated: _SpecialForm
_AnnotatedAlias: Any # undocumented
Expand Down