Skip to content

Commit

Permalink
Sync typeshed (#16266)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Oct 15, 2023
1 parent 2e52e98 commit feb0fa7
Show file tree
Hide file tree
Showing 26 changed files with 363 additions and 143 deletions.
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ _dummy_threading: 2.7-3.8
_heapq: 2.7-
_imp: 3.0-
_json: 2.7-
_locale: 2.7-
_markupbase: 2.7-
_msi: 2.7-
_operator: 3.4-
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_ast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ if sys.version_info >= (3, 12):
name: _Identifier

class TypeAlias(stmt):
__match_args__ = ("name", "typeparams", "value")
__match_args__ = ("name", "type_params", "value")
name: Name
type_params: list[type_param]
value: expr
2 changes: 2 additions & 0 deletions mypy/typeshed/stdlib/_ctypes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ if sys.platform == "win32":
def FormatError(code: int = ...) -> str: ...
def get_last_error() -> int: ...
def set_last_error(value: int) -> int: ...
def LoadLibrary(__name: str, __load_flags: int = 0) -> int: ...
def FreeLibrary(__handle: int) -> None: ...

class _CDataMeta(type):
# By default mypy complains about the following two methods, because strictly speaking cls
Expand Down
3 changes: 2 additions & 1 deletion mypy/typeshed/stdlib/_curses.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ if sys.platform != "win32":
A_DIM: int
A_HORIZONTAL: int
A_INVIS: int
A_ITALIC: int
if sys.platform != "darwin":
A_ITALIC: int
A_LEFT: int
A_LOW: int
A_NORMAL: int
Expand Down
100 changes: 100 additions & 0 deletions mypy/typeshed/stdlib/_locale.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import sys
from _typeshed import StrPath
from collections.abc import Iterable, Mapping

LC_CTYPE: int
LC_COLLATE: int
LC_TIME: int
LC_MONETARY: int
LC_NUMERIC: int
LC_ALL: int
CHAR_MAX: int

def setlocale(category: int, locale: str | Iterable[str | None] | None = None) -> str: ...
def localeconv() -> Mapping[str, int | str | list[int]]: ...

if sys.version_info >= (3, 11):
def getencoding() -> str: ...

def strcoll(__os1: str, __os2: str) -> int: ...
def strxfrm(__string: str) -> str: ...

# native gettext functions
# https://docs.python.org/3/library/locale.html#access-to-message-catalogs
# https://github.com/python/cpython/blob/f4c03484da59049eb62a9bf7777b963e2267d187/Modules/_localemodule.c#L626
if sys.platform != "win32":
LC_MESSAGES: int

ABDAY_1: int
ABDAY_2: int
ABDAY_3: int
ABDAY_4: int
ABDAY_5: int
ABDAY_6: int
ABDAY_7: int

ABMON_1: int
ABMON_2: int
ABMON_3: int
ABMON_4: int
ABMON_5: int
ABMON_6: int
ABMON_7: int
ABMON_8: int
ABMON_9: int
ABMON_10: int
ABMON_11: int
ABMON_12: int

DAY_1: int
DAY_2: int
DAY_3: int
DAY_4: int
DAY_5: int
DAY_6: int
DAY_7: int

ERA: int
ERA_D_T_FMT: int
ERA_D_FMT: int
ERA_T_FMT: int

MON_1: int
MON_2: int
MON_3: int
MON_4: int
MON_5: int
MON_6: int
MON_7: int
MON_8: int
MON_9: int
MON_10: int
MON_11: int
MON_12: int

CODESET: int
D_T_FMT: int
D_FMT: int
T_FMT: int
T_FMT_AMPM: int
AM_STR: int
PM_STR: int

RADIXCHAR: int
THOUSEP: int
YESEXPR: int
NOEXPR: int
CRNCYSTR: int
ALT_DIGITS: int

def nl_langinfo(__key: int) -> str: ...

# This is dependent on `libintl.h` which is a part of `gettext`
# system dependency. These functions might be missing.
# But, we always say that they are present.
def gettext(__msg: str) -> str: ...
def dgettext(__domain: str | None, __msg: str) -> str: ...
def dcgettext(__domain: str | None, __msg: str, __category: int) -> str: ...
def textdomain(__domain: str | None) -> str: ...
def bindtextdomain(__domain: str, __dir: StrPath | None) -> str: ...
def bind_textdomain_codeset(__domain: str, __codeset: str | None) -> str | None: ...
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/_msi.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys

if sys.platform == "win32":
class MSIError(Exception): ...
# Actual typename View, not exposed by the implementation
class _View:
def Execute(self, params: _Record | None = ...) -> None: ...
Expand Down
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/_winapi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,4 @@ if sys.platform == "win32":

if sys.version_info >= (3, 12):
def CopyFile2(existing_file_name: str, new_file_name: str, flags: int, progress_routine: int | None = None) -> int: ...
def NeedCurrentDirectoryForExePath(__exe_name: str) -> bool: ...
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/argparse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,11 @@ if sys.version_info >= (3, 12):
option_strings: Sequence[str],
dest: str,
default: _T | str | None = None,
type: Callable[[str], _T] | FileType | None = sentinel, # noqa: Y011
choices: Iterable[_T] | None = sentinel, # noqa: Y011
type: Callable[[str], _T] | FileType | None = sentinel,
choices: Iterable[_T] | None = sentinel,
required: bool = False,
help: str | None = None,
metavar: str | tuple[str, ...] | None = sentinel, # noqa: Y011
metavar: str | tuple[str, ...] | None = sentinel,
) -> None: ...

elif sys.version_info >= (3, 9):
Expand Down
68 changes: 63 additions & 5 deletions mypy/typeshed/stdlib/asyncio/tasks.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ _T2 = TypeVar("_T2")
_T3 = TypeVar("_T3")
_T4 = TypeVar("_T4")
_T5 = TypeVar("_T5")
_T6 = TypeVar("_T6")
_FT = TypeVar("_FT", bound=Future[Any])
_FutureLike: TypeAlias = Future[_T] | Generator[Any, None, _T] | Awaitable[_T]
_TaskYieldType: TypeAlias = Future[object] | None
Expand Down Expand Up @@ -131,6 +132,19 @@ if sys.version_info >= (3, 10):
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
__coro_or_future3: _FutureLike[_T3],
__coro_or_future4: _FutureLike[_T4],
__coro_or_future5: _FutureLike[_T5],
__coro_or_future6: _FutureLike[_T6],
*,
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ...
@overload
def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: Literal[False] = False) -> Future[list[_T]]: ... # type: ignore[misc]
@overload
def gather(__coro_or_future1: _FutureLike[_T1], *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... # type: ignore[misc]
@overload
def gather( # type: ignore[misc]
Expand Down Expand Up @@ -166,7 +180,27 @@ if sys.version_info >= (3, 10):
tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]
]: ...
@overload
def gather(*coros_or_futures: _FutureLike[Any], return_exceptions: bool = False) -> Future[list[Any]]: ...
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
__coro_or_future3: _FutureLike[_T3],
__coro_or_future4: _FutureLike[_T4],
__coro_or_future5: _FutureLike[_T5],
__coro_or_future6: _FutureLike[_T6],
*,
return_exceptions: bool,
) -> Future[
tuple[
_T1 | BaseException,
_T2 | BaseException,
_T3 | BaseException,
_T4 | BaseException,
_T5 | BaseException,
_T6 | BaseException,
]
]: ...
@overload
def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: bool) -> Future[list[_T | BaseException]]: ...

else:
@overload
Expand Down Expand Up @@ -212,6 +246,22 @@ else:
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
__coro_or_future3: _FutureLike[_T3],
__coro_or_future4: _FutureLike[_T4],
__coro_or_future5: _FutureLike[_T5],
__coro_or_future6: _FutureLike[_T6],
*,
loop: AbstractEventLoop | None = None,
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ...
@overload
def gather( # type: ignore[misc]
*coros_or_futures: _FutureLike[_T], loop: AbstractEventLoop | None = None, return_exceptions: Literal[False] = False
) -> Future[list[_T]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1], *, loop: AbstractEventLoop | None = None, return_exceptions: bool
) -> Future[tuple[_T1 | BaseException]]: ...
Expand Down Expand Up @@ -249,16 +299,24 @@ else:
__coro_or_future3: _FutureLike[_T3],
__coro_or_future4: _FutureLike[_T4],
__coro_or_future5: _FutureLike[_T5],
__coro_or_future6: _FutureLike[_T6],
*,
loop: AbstractEventLoop | None = None,
return_exceptions: bool,
) -> Future[
tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]
tuple[
_T1 | BaseException,
_T2 | BaseException,
_T3 | BaseException,
_T4 | BaseException,
_T5 | BaseException,
_T6 | BaseException,
]
]: ...
@overload
def gather(
*coros_or_futures: _FutureLike[Any], loop: AbstractEventLoop | None = None, return_exceptions: bool = False
) -> Future[list[Any]]: ...
def gather( # type: ignore[misc]
*coros_or_futures: _FutureLike[_T], loop: AbstractEventLoop | None = None, return_exceptions: bool
) -> Future[list[_T | BaseException]]: ...

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

Expand Down
12 changes: 11 additions & 1 deletion mypy/typeshed/stdlib/asyncio/windows_events.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import socket
import sys
from _typeshed import Incomplete, WriteableBuffer
from _typeshed import Incomplete, ReadableBuffer, WriteableBuffer
from collections.abc import Callable
from typing import IO, Any, ClassVar, NoReturn
from typing_extensions import Literal
Expand Down Expand Up @@ -48,6 +48,12 @@ if sys.platform == "win32":
def select(self, timeout: int | None = None) -> list[futures.Future[Any]]: ...
def recv(self, conn: socket.socket, nbytes: int, flags: int = 0) -> futures.Future[bytes]: ...
def recv_into(self, conn: socket.socket, buf: WriteableBuffer, flags: int = 0) -> futures.Future[Any]: ...
def recvfrom(
self, conn: socket.socket, nbytes: int, flags: int = 0
) -> futures.Future[tuple[bytes, socket._RetAddress]]: ...
def sendto(
self, conn: socket.socket, buf: ReadableBuffer, flags: int = 0, addr: socket._Address | None = None
) -> futures.Future[int]: ...
def send(self, conn: socket.socket, buf: WriteableBuffer, flags: int = 0) -> futures.Future[Any]: ...
def accept(self, listener: socket.socket) -> futures.Future[Any]: ...
def connect(
Expand All @@ -60,6 +66,10 @@ if sys.platform == "win32":
async def connect_pipe(self, address: str) -> windows_utils.PipeHandle: ...
def wait_for_handle(self, handle: windows_utils.PipeHandle, timeout: int | None = None) -> bool: ...
def close(self) -> None: ...
if sys.version_info >= (3, 11):
def recvfrom_into(
self, conn: socket.socket, buf: WriteableBuffer, flags: int = 0
) -> futures.Future[tuple[int, socket._RetAddress]]: ...
SelectorEventLoop = _WindowsSelectorEventLoop

class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
Expand Down
Loading

0 comments on commit feb0fa7

Please sign in to comment.