Skip to content

Commit 40985b4

Browse files
authored
Fix various __all__ bugs and omissions (#7618)
1 parent f87e811 commit 40985b4

File tree

5 files changed

+204
-40
lines changed

5 files changed

+204
-40
lines changed

stdlib/_pydecimal.pyi

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,85 @@
1+
import sys
2+
13
# This is a slight lie, the implementations aren't exactly identical
24
# However, in all likelihood, the differences are inconsequential
35
from decimal import *
6+
7+
if sys.version_info >= (3, 7):
8+
__all__ = [
9+
"Decimal",
10+
"Context",
11+
"DecimalTuple",
12+
"DefaultContext",
13+
"BasicContext",
14+
"ExtendedContext",
15+
"DecimalException",
16+
"Clamped",
17+
"InvalidOperation",
18+
"DivisionByZero",
19+
"Inexact",
20+
"Rounded",
21+
"Subnormal",
22+
"Overflow",
23+
"Underflow",
24+
"FloatOperation",
25+
"DivisionImpossible",
26+
"InvalidContext",
27+
"ConversionSyntax",
28+
"DivisionUndefined",
29+
"ROUND_DOWN",
30+
"ROUND_HALF_UP",
31+
"ROUND_HALF_EVEN",
32+
"ROUND_CEILING",
33+
"ROUND_FLOOR",
34+
"ROUND_UP",
35+
"ROUND_HALF_DOWN",
36+
"ROUND_05UP",
37+
"setcontext",
38+
"getcontext",
39+
"localcontext",
40+
"MAX_PREC",
41+
"MAX_EMAX",
42+
"MIN_EMIN",
43+
"MIN_ETINY",
44+
"HAVE_THREADS",
45+
"HAVE_CONTEXTVAR",
46+
]
47+
else:
48+
__all__ = [
49+
"Decimal",
50+
"Context",
51+
"DecimalTuple",
52+
"DefaultContext",
53+
"BasicContext",
54+
"ExtendedContext",
55+
"DecimalException",
56+
"Clamped",
57+
"InvalidOperation",
58+
"DivisionByZero",
59+
"Inexact",
60+
"Rounded",
61+
"Subnormal",
62+
"Overflow",
63+
"Underflow",
64+
"FloatOperation",
65+
"DivisionImpossible",
66+
"InvalidContext",
67+
"ConversionSyntax",
68+
"DivisionUndefined",
69+
"ROUND_DOWN",
70+
"ROUND_HALF_UP",
71+
"ROUND_HALF_EVEN",
72+
"ROUND_CEILING",
73+
"ROUND_FLOOR",
74+
"ROUND_UP",
75+
"ROUND_HALF_DOWN",
76+
"ROUND_05UP",
77+
"setcontext",
78+
"getcontext",
79+
"localcontext",
80+
"MAX_PREC",
81+
"MAX_EMAX",
82+
"MIN_EMIN",
83+
"MIN_ETINY",
84+
"HAVE_THREADS",
85+
]

stdlib/calendar.pyi

Lines changed: 61 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,67 @@ from collections.abc import Iterable, Sequence
44
from time import struct_time
55
from typing_extensions import Literal
66

7-
__all__ = [
8-
"IllegalMonthError",
9-
"IllegalWeekdayError",
10-
"setfirstweekday",
11-
"firstweekday",
12-
"isleap",
13-
"leapdays",
14-
"weekday",
15-
"monthrange",
16-
"monthcalendar",
17-
"prmonth",
18-
"month",
19-
"prcal",
20-
"calendar",
21-
"timegm",
22-
"month_name",
23-
"month_abbr",
24-
"day_name",
25-
"day_abbr",
26-
"Calendar",
27-
"TextCalendar",
28-
"HTMLCalendar",
29-
"LocaleTextCalendar",
30-
"LocaleHTMLCalendar",
31-
"weekheader",
32-
]
7+
if sys.version_info >= (3, 10):
8+
__all__ = [
9+
"IllegalMonthError",
10+
"IllegalWeekdayError",
11+
"setfirstweekday",
12+
"firstweekday",
13+
"isleap",
14+
"leapdays",
15+
"weekday",
16+
"monthrange",
17+
"monthcalendar",
18+
"prmonth",
19+
"month",
20+
"prcal",
21+
"calendar",
22+
"timegm",
23+
"month_name",
24+
"month_abbr",
25+
"day_name",
26+
"day_abbr",
27+
"Calendar",
28+
"TextCalendar",
29+
"HTMLCalendar",
30+
"LocaleTextCalendar",
31+
"LocaleHTMLCalendar",
32+
"weekheader",
33+
"FRIDAY",
34+
"MONDAY",
35+
"SATURDAY",
36+
"SUNDAY",
37+
"THURSDAY",
38+
"TUESDAY",
39+
"WEDNESDAY",
40+
]
41+
else:
42+
__all__ = [
43+
"IllegalMonthError",
44+
"IllegalWeekdayError",
45+
"setfirstweekday",
46+
"firstweekday",
47+
"isleap",
48+
"leapdays",
49+
"weekday",
50+
"monthrange",
51+
"monthcalendar",
52+
"prmonth",
53+
"month",
54+
"prcal",
55+
"calendar",
56+
"timegm",
57+
"month_name",
58+
"month_abbr",
59+
"day_name",
60+
"day_abbr",
61+
"Calendar",
62+
"TextCalendar",
63+
"HTMLCalendar",
64+
"LocaleTextCalendar",
65+
"LocaleHTMLCalendar",
66+
"weekheader",
67+
]
3368

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

stdlib/poplib.pyi

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import socket
22
import ssl
3-
import sys
43
from typing import Any, BinaryIO, NoReturn, Pattern, overload
54
from typing_extensions import Literal
65

7-
if sys.version_info >= (3, 10):
8-
__all__ = ["POP3", "error_proto", "POP3_SSL"]
9-
else:
10-
__all__ = ["POP3", "error_proto"]
6+
__all__ = ["POP3", "error_proto", "POP3_SSL"]
117

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

stdlib/tty.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import sys
22
from typing import IO
33

44
if sys.platform != "win32":
5+
__all__ = ["setraw", "setcbreak"]
6+
57
_FD = int | IO[str]
68

79
# XXX: Undocumented integer constants

stdlib/typing_extensions.pyi

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,56 @@ from typing import ( # noqa: Y022,Y027
3030
overload as overload,
3131
)
3232

33+
__all__ = [
34+
"ClassVar",
35+
"Concatenate",
36+
"Final",
37+
"LiteralString",
38+
"ParamSpec",
39+
"Self",
40+
"Type",
41+
"TypeVarTuple",
42+
"Unpack",
43+
"Awaitable",
44+
"AsyncIterator",
45+
"AsyncIterable",
46+
"Coroutine",
47+
"AsyncGenerator",
48+
"AsyncContextManager",
49+
"ChainMap",
50+
"ContextManager",
51+
"Counter",
52+
"Deque",
53+
"DefaultDict",
54+
"OrderedDict",
55+
"TypedDict",
56+
"SupportsIndex",
57+
"Annotated",
58+
"assert_never",
59+
"dataclass_transform",
60+
"final",
61+
"IntVar",
62+
"is_typeddict",
63+
"Literal",
64+
"NewType",
65+
"overload",
66+
"Protocol",
67+
"reveal_type",
68+
"runtime",
69+
"runtime_checkable",
70+
"Text",
71+
"TypeAlias",
72+
"TypeGuard",
73+
"TYPE_CHECKING",
74+
"Never",
75+
"NoReturn",
76+
"Required",
77+
"NotRequired",
78+
"get_args",
79+
"get_origin",
80+
"get_type_hints",
81+
]
82+
3383
_T = TypeVar("_T")
3484
_F = TypeVar("_F", bound=Callable[..., Any])
3585
_TC = TypeVar("_TC", bound=Type[object])
@@ -82,15 +132,14 @@ TypedDict: object
82132

83133
OrderedDict = _Alias()
84134

85-
if sys.version_info >= (3, 7):
86-
def get_type_hints(
87-
obj: Callable[..., Any],
88-
globalns: dict[str, Any] | None = ...,
89-
localns: dict[str, Any] | None = ...,
90-
include_extras: bool = ...,
91-
) -> dict[str, Any]: ...
92-
def get_args(tp: Any) -> tuple[Any, ...]: ...
93-
def get_origin(tp: Any) -> Any | None: ...
135+
def get_type_hints(
136+
obj: Callable[..., Any],
137+
globalns: dict[str, Any] | None = ...,
138+
localns: dict[str, Any] | None = ...,
139+
include_extras: bool = ...,
140+
) -> dict[str, Any]: ...
141+
def get_args(tp: Any) -> tuple[Any, ...]: ...
142+
def get_origin(tp: Any) -> Any | None: ...
94143

95144
Annotated: _SpecialForm
96145
_AnnotatedAlias: Any # undocumented

0 commit comments

Comments
 (0)