Skip to content

Commit feb0fa7

Browse files
Sync typeshed (#16266)
1 parent 2e52e98 commit feb0fa7

26 files changed

+363
-143
lines changed

mypy/typeshed/stdlib/VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ _dummy_threading: 2.7-3.8
3535
_heapq: 2.7-
3636
_imp: 3.0-
3737
_json: 2.7-
38+
_locale: 2.7-
3839
_markupbase: 2.7-
3940
_msi: 2.7-
4041
_operator: 3.4-

mypy/typeshed/stdlib/_ast.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ if sys.version_info >= (3, 12):
602602
name: _Identifier
603603

604604
class TypeAlias(stmt):
605-
__match_args__ = ("name", "typeparams", "value")
605+
__match_args__ = ("name", "type_params", "value")
606606
name: Name
607607
type_params: list[type_param]
608608
value: expr

mypy/typeshed/stdlib/_ctypes.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ if sys.platform == "win32":
4444
def FormatError(code: int = ...) -> str: ...
4545
def get_last_error() -> int: ...
4646
def set_last_error(value: int) -> int: ...
47+
def LoadLibrary(__name: str, __load_flags: int = 0) -> int: ...
48+
def FreeLibrary(__handle: int) -> None: ...
4749

4850
class _CDataMeta(type):
4951
# By default mypy complains about the following two methods, because strictly speaking cls

mypy/typeshed/stdlib/_curses.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ if sys.platform != "win32":
6161
A_DIM: int
6262
A_HORIZONTAL: int
6363
A_INVIS: int
64-
A_ITALIC: int
64+
if sys.platform != "darwin":
65+
A_ITALIC: int
6566
A_LEFT: int
6667
A_LOW: int
6768
A_NORMAL: int

mypy/typeshed/stdlib/_locale.pyi

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import sys
2+
from _typeshed import StrPath
3+
from collections.abc import Iterable, Mapping
4+
5+
LC_CTYPE: int
6+
LC_COLLATE: int
7+
LC_TIME: int
8+
LC_MONETARY: int
9+
LC_NUMERIC: int
10+
LC_ALL: int
11+
CHAR_MAX: int
12+
13+
def setlocale(category: int, locale: str | Iterable[str | None] | None = None) -> str: ...
14+
def localeconv() -> Mapping[str, int | str | list[int]]: ...
15+
16+
if sys.version_info >= (3, 11):
17+
def getencoding() -> str: ...
18+
19+
def strcoll(__os1: str, __os2: str) -> int: ...
20+
def strxfrm(__string: str) -> str: ...
21+
22+
# native gettext functions
23+
# https://docs.python.org/3/library/locale.html#access-to-message-catalogs
24+
# https://github.com/python/cpython/blob/f4c03484da59049eb62a9bf7777b963e2267d187/Modules/_localemodule.c#L626
25+
if sys.platform != "win32":
26+
LC_MESSAGES: int
27+
28+
ABDAY_1: int
29+
ABDAY_2: int
30+
ABDAY_3: int
31+
ABDAY_4: int
32+
ABDAY_5: int
33+
ABDAY_6: int
34+
ABDAY_7: int
35+
36+
ABMON_1: int
37+
ABMON_2: int
38+
ABMON_3: int
39+
ABMON_4: int
40+
ABMON_5: int
41+
ABMON_6: int
42+
ABMON_7: int
43+
ABMON_8: int
44+
ABMON_9: int
45+
ABMON_10: int
46+
ABMON_11: int
47+
ABMON_12: int
48+
49+
DAY_1: int
50+
DAY_2: int
51+
DAY_3: int
52+
DAY_4: int
53+
DAY_5: int
54+
DAY_6: int
55+
DAY_7: int
56+
57+
ERA: int
58+
ERA_D_T_FMT: int
59+
ERA_D_FMT: int
60+
ERA_T_FMT: int
61+
62+
MON_1: int
63+
MON_2: int
64+
MON_3: int
65+
MON_4: int
66+
MON_5: int
67+
MON_6: int
68+
MON_7: int
69+
MON_8: int
70+
MON_9: int
71+
MON_10: int
72+
MON_11: int
73+
MON_12: int
74+
75+
CODESET: int
76+
D_T_FMT: int
77+
D_FMT: int
78+
T_FMT: int
79+
T_FMT_AMPM: int
80+
AM_STR: int
81+
PM_STR: int
82+
83+
RADIXCHAR: int
84+
THOUSEP: int
85+
YESEXPR: int
86+
NOEXPR: int
87+
CRNCYSTR: int
88+
ALT_DIGITS: int
89+
90+
def nl_langinfo(__key: int) -> str: ...
91+
92+
# This is dependent on `libintl.h` which is a part of `gettext`
93+
# system dependency. These functions might be missing.
94+
# But, we always say that they are present.
95+
def gettext(__msg: str) -> str: ...
96+
def dgettext(__domain: str | None, __msg: str) -> str: ...
97+
def dcgettext(__domain: str | None, __msg: str, __category: int) -> str: ...
98+
def textdomain(__domain: str | None) -> str: ...
99+
def bindtextdomain(__domain: str, __dir: StrPath | None) -> str: ...
100+
def bind_textdomain_codeset(__domain: str, __codeset: str | None) -> str | None: ...

mypy/typeshed/stdlib/_msi.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
22

33
if sys.platform == "win32":
4+
class MSIError(Exception): ...
45
# Actual typename View, not exposed by the implementation
56
class _View:
67
def Execute(self, params: _Record | None = ...) -> None: ...

mypy/typeshed/stdlib/_winapi.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,4 @@ if sys.platform == "win32":
255255

256256
if sys.version_info >= (3, 12):
257257
def CopyFile2(existing_file_name: str, new_file_name: str, flags: int, progress_routine: int | None = None) -> int: ...
258+
def NeedCurrentDirectoryForExePath(__exe_name: str) -> bool: ...

mypy/typeshed/stdlib/argparse.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,11 @@ if sys.version_info >= (3, 12):
342342
option_strings: Sequence[str],
343343
dest: str,
344344
default: _T | str | None = None,
345-
type: Callable[[str], _T] | FileType | None = sentinel, # noqa: Y011
346-
choices: Iterable[_T] | None = sentinel, # noqa: Y011
345+
type: Callable[[str], _T] | FileType | None = sentinel,
346+
choices: Iterable[_T] | None = sentinel,
347347
required: bool = False,
348348
help: str | None = None,
349-
metavar: str | tuple[str, ...] | None = sentinel, # noqa: Y011
349+
metavar: str | tuple[str, ...] | None = sentinel,
350350
) -> None: ...
351351

352352
elif sys.version_info >= (3, 9):

mypy/typeshed/stdlib/asyncio/tasks.pyi

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ _T2 = TypeVar("_T2")
6868
_T3 = TypeVar("_T3")
6969
_T4 = TypeVar("_T4")
7070
_T5 = TypeVar("_T5")
71+
_T6 = TypeVar("_T6")
7172
_FT = TypeVar("_FT", bound=Future[Any])
7273
_FutureLike: TypeAlias = Future[_T] | Generator[Any, None, _T] | Awaitable[_T]
7374
_TaskYieldType: TypeAlias = Future[object] | None
@@ -131,6 +132,19 @@ if sys.version_info >= (3, 10):
131132
return_exceptions: Literal[False] = False,
132133
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ...
133134
@overload
135+
def gather( # type: ignore[misc]
136+
__coro_or_future1: _FutureLike[_T1],
137+
__coro_or_future2: _FutureLike[_T2],
138+
__coro_or_future3: _FutureLike[_T3],
139+
__coro_or_future4: _FutureLike[_T4],
140+
__coro_or_future5: _FutureLike[_T5],
141+
__coro_or_future6: _FutureLike[_T6],
142+
*,
143+
return_exceptions: Literal[False] = False,
144+
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ...
145+
@overload
146+
def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: Literal[False] = False) -> Future[list[_T]]: ... # type: ignore[misc]
147+
@overload
134148
def gather(__coro_or_future1: _FutureLike[_T1], *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... # type: ignore[misc]
135149
@overload
136150
def gather( # type: ignore[misc]
@@ -166,7 +180,27 @@ if sys.version_info >= (3, 10):
166180
tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]
167181
]: ...
168182
@overload
169-
def gather(*coros_or_futures: _FutureLike[Any], return_exceptions: bool = False) -> Future[list[Any]]: ...
183+
def gather( # type: ignore[misc]
184+
__coro_or_future1: _FutureLike[_T1],
185+
__coro_or_future2: _FutureLike[_T2],
186+
__coro_or_future3: _FutureLike[_T3],
187+
__coro_or_future4: _FutureLike[_T4],
188+
__coro_or_future5: _FutureLike[_T5],
189+
__coro_or_future6: _FutureLike[_T6],
190+
*,
191+
return_exceptions: bool,
192+
) -> Future[
193+
tuple[
194+
_T1 | BaseException,
195+
_T2 | BaseException,
196+
_T3 | BaseException,
197+
_T4 | BaseException,
198+
_T5 | BaseException,
199+
_T6 | BaseException,
200+
]
201+
]: ...
202+
@overload
203+
def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: bool) -> Future[list[_T | BaseException]]: ...
170204

171205
else:
172206
@overload
@@ -212,6 +246,22 @@ else:
212246
return_exceptions: Literal[False] = False,
213247
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ...
214248
@overload
249+
def gather( # type: ignore[misc]
250+
__coro_or_future1: _FutureLike[_T1],
251+
__coro_or_future2: _FutureLike[_T2],
252+
__coro_or_future3: _FutureLike[_T3],
253+
__coro_or_future4: _FutureLike[_T4],
254+
__coro_or_future5: _FutureLike[_T5],
255+
__coro_or_future6: _FutureLike[_T6],
256+
*,
257+
loop: AbstractEventLoop | None = None,
258+
return_exceptions: Literal[False] = False,
259+
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ...
260+
@overload
261+
def gather( # type: ignore[misc]
262+
*coros_or_futures: _FutureLike[_T], loop: AbstractEventLoop | None = None, return_exceptions: Literal[False] = False
263+
) -> Future[list[_T]]: ...
264+
@overload
215265
def gather( # type: ignore[misc]
216266
__coro_or_future1: _FutureLike[_T1], *, loop: AbstractEventLoop | None = None, return_exceptions: bool
217267
) -> Future[tuple[_T1 | BaseException]]: ...
@@ -249,16 +299,24 @@ else:
249299
__coro_or_future3: _FutureLike[_T3],
250300
__coro_or_future4: _FutureLike[_T4],
251301
__coro_or_future5: _FutureLike[_T5],
302+
__coro_or_future6: _FutureLike[_T6],
252303
*,
253304
loop: AbstractEventLoop | None = None,
254305
return_exceptions: bool,
255306
) -> Future[
256-
tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]
307+
tuple[
308+
_T1 | BaseException,
309+
_T2 | BaseException,
310+
_T3 | BaseException,
311+
_T4 | BaseException,
312+
_T5 | BaseException,
313+
_T6 | BaseException,
314+
]
257315
]: ...
258316
@overload
259-
def gather(
260-
*coros_or_futures: _FutureLike[Any], loop: AbstractEventLoop | None = None, return_exceptions: bool = False
261-
) -> Future[list[Any]]: ...
317+
def gather( # type: ignore[misc]
318+
*coros_or_futures: _FutureLike[_T], loop: AbstractEventLoop | None = None, return_exceptions: bool
319+
) -> Future[list[_T | BaseException]]: ...
262320

263321
def run_coroutine_threadsafe(coro: _FutureLike[_T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ...
264322

mypy/typeshed/stdlib/asyncio/windows_events.pyi

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import socket
22
import sys
3-
from _typeshed import Incomplete, WriteableBuffer
3+
from _typeshed import Incomplete, ReadableBuffer, WriteableBuffer
44
from collections.abc import Callable
55
from typing import IO, Any, ClassVar, NoReturn
66
from typing_extensions import Literal
@@ -48,6 +48,12 @@ if sys.platform == "win32":
4848
def select(self, timeout: int | None = None) -> list[futures.Future[Any]]: ...
4949
def recv(self, conn: socket.socket, nbytes: int, flags: int = 0) -> futures.Future[bytes]: ...
5050
def recv_into(self, conn: socket.socket, buf: WriteableBuffer, flags: int = 0) -> futures.Future[Any]: ...
51+
def recvfrom(
52+
self, conn: socket.socket, nbytes: int, flags: int = 0
53+
) -> futures.Future[tuple[bytes, socket._RetAddress]]: ...
54+
def sendto(
55+
self, conn: socket.socket, buf: ReadableBuffer, flags: int = 0, addr: socket._Address | None = None
56+
) -> futures.Future[int]: ...
5157
def send(self, conn: socket.socket, buf: WriteableBuffer, flags: int = 0) -> futures.Future[Any]: ...
5258
def accept(self, listener: socket.socket) -> futures.Future[Any]: ...
5359
def connect(
@@ -60,6 +66,10 @@ if sys.platform == "win32":
6066
async def connect_pipe(self, address: str) -> windows_utils.PipeHandle: ...
6167
def wait_for_handle(self, handle: windows_utils.PipeHandle, timeout: int | None = None) -> bool: ...
6268
def close(self) -> None: ...
69+
if sys.version_info >= (3, 11):
70+
def recvfrom_into(
71+
self, conn: socket.socket, buf: WriteableBuffer, flags: int = 0
72+
) -> futures.Future[tuple[int, socket._RetAddress]]: ...
6373
SelectorEventLoop = _WindowsSelectorEventLoop
6474

6575
class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy):

0 commit comments

Comments
 (0)