Skip to content

Commit f8195bc

Browse files
Sync typeshed (#17772)
Source commit: python/typeshed@9e506eb
1 parent 72c413d commit f8195bc

File tree

16 files changed

+214
-106
lines changed

16 files changed

+214
-106
lines changed

mypy/typeshed/stdlib/VERSIONS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ _json: 3.0-
4141
_locale: 3.0-
4242
_lsprof: 3.0-
4343
_markupbase: 3.0-
44-
_msi: 3.0-
44+
_msi: 3.0-3.12
4545
_operator: 3.4-
4646
_osx_support: 3.0-
4747
_posixsubprocess: 3.2-

mypy/typeshed/stdlib/_curses.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ class _CursesWindow:
493493
def instr(self, y: int, x: int, n: int = ...) -> bytes: ...
494494
def is_linetouched(self, line: int, /) -> bool: ...
495495
def is_wintouched(self) -> bool: ...
496-
def keypad(self, yes: bool) -> None: ...
496+
def keypad(self, yes: bool, /) -> None: ...
497497
def leaveok(self, yes: bool) -> None: ...
498498
def move(self, new_y: int, new_x: int) -> None: ...
499499
def mvderwin(self, y: int, x: int) -> None: ...

mypy/typeshed/stdlib/_locale.pyi

Lines changed: 85 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
11
import sys
22
from _typeshed import StrPath
3-
from collections.abc import Mapping
3+
from typing import Final, Literal, TypedDict, type_check_only
44

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
5+
@type_check_only
6+
class _LocaleConv(TypedDict):
7+
decimal_point: str
8+
grouping: list[int]
9+
thousands_sep: str
10+
int_curr_symbol: str
11+
currency_symbol: str
12+
p_cs_precedes: Literal[0, 1, 127]
13+
n_cs_precedes: Literal[0, 1, 127]
14+
p_sep_by_space: Literal[0, 1, 127]
15+
n_sep_by_space: Literal[0, 1, 127]
16+
mon_decimal_point: str
17+
frac_digits: int
18+
int_frac_digits: int
19+
mon_thousands_sep: str
20+
mon_grouping: list[int]
21+
positive_sign: str
22+
negative_sign: str
23+
p_sign_posn: Literal[0, 1, 2, 3, 4, 127]
24+
n_sign_posn: Literal[0, 1, 2, 3, 4, 127]
25+
26+
LC_CTYPE: Final[int]
27+
LC_COLLATE: Final[int]
28+
LC_TIME: Final[int]
29+
LC_MONETARY: Final[int]
30+
LC_NUMERIC: Final[int]
31+
LC_ALL: Final[int]
32+
CHAR_MAX: Final = 127
1233

1334
def setlocale(category: int, locale: str | None = None, /) -> str: ...
14-
def localeconv() -> Mapping[str, int | str | list[int]]: ...
35+
def localeconv() -> _LocaleConv: ...
1536

1637
if sys.version_info >= (3, 11):
1738
def getencoding() -> str: ...
@@ -25,67 +46,67 @@ def strxfrm(string: str, /) -> str: ...
2546
if sys.platform != "win32":
2647
LC_MESSAGES: int
2748

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
49+
ABDAY_1: Final[int]
50+
ABDAY_2: Final[int]
51+
ABDAY_3: Final[int]
52+
ABDAY_4: Final[int]
53+
ABDAY_5: Final[int]
54+
ABDAY_6: Final[int]
55+
ABDAY_7: Final[int]
3556

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
57+
ABMON_1: Final[int]
58+
ABMON_2: Final[int]
59+
ABMON_3: Final[int]
60+
ABMON_4: Final[int]
61+
ABMON_5: Final[int]
62+
ABMON_6: Final[int]
63+
ABMON_7: Final[int]
64+
ABMON_8: Final[int]
65+
ABMON_9: Final[int]
66+
ABMON_10: Final[int]
67+
ABMON_11: Final[int]
68+
ABMON_12: Final[int]
4869

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
70+
DAY_1: Final[int]
71+
DAY_2: Final[int]
72+
DAY_3: Final[int]
73+
DAY_4: Final[int]
74+
DAY_5: Final[int]
75+
DAY_6: Final[int]
76+
DAY_7: Final[int]
5677

57-
ERA: int
58-
ERA_D_T_FMT: int
59-
ERA_D_FMT: int
60-
ERA_T_FMT: int
78+
ERA: Final[int]
79+
ERA_D_T_FMT: Final[int]
80+
ERA_D_FMT: Final[int]
81+
ERA_T_FMT: Final[int]
6182

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
83+
MON_1: Final[int]
84+
MON_2: Final[int]
85+
MON_3: Final[int]
86+
MON_4: Final[int]
87+
MON_5: Final[int]
88+
MON_6: Final[int]
89+
MON_7: Final[int]
90+
MON_8: Final[int]
91+
MON_9: Final[int]
92+
MON_10: Final[int]
93+
MON_11: Final[int]
94+
MON_12: Final[int]
7495

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
96+
CODESET: Final[int]
97+
D_T_FMT: Final[int]
98+
D_FMT: Final[int]
99+
T_FMT: Final[int]
100+
T_FMT_AMPM: Final[int]
101+
AM_STR: Final[int]
102+
PM_STR: Final[int]
82103

83-
RADIXCHAR: int
84-
THOUSEP: int
85-
YESEXPR: int
86-
NOEXPR: int
87-
CRNCYSTR: int
88-
ALT_DIGITS: int
104+
RADIXCHAR: Final[int]
105+
THOUSEP: Final[int]
106+
YESEXPR: Final[int]
107+
NOEXPR: Final[int]
108+
CRNCYSTR: Final[int]
109+
ALT_DIGITS: Final[int]
89110

90111
def nl_langinfo(key: int, /) -> str: ...
91112

mypy/typeshed/stdlib/_winapi.pyi

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,20 @@ if sys.platform == "win32":
9999
SEC_RESERVE: Final = 0x4000000
100100
SEC_WRITECOMBINE: Final = 0x40000000
101101

102+
if sys.version_info >= (3, 13):
103+
STARTF_FORCEOFFFEEDBACK: Final = 0x80
104+
STARTF_FORCEONFEEDBACK: Final = 0x40
105+
STARTF_PREVENTPINNING: Final = 0x2000
106+
STARTF_RUNFULLSCREEN: Final = 0x20
107+
STARTF_TITLEISAPPID: Final = 0x1000
108+
STARTF_TITLEISLINKNAME: Final = 0x800
109+
STARTF_UNTRUSTEDSOURCE: Final = 0x8000
110+
STARTF_USECOUNTCHARS: Final = 0x8
111+
STARTF_USEFILLATTRIBUTE: Final = 0x10
112+
STARTF_USEHOTKEY: Final = 0x200
113+
STARTF_USEPOSITION: Final = 0x4
114+
STARTF_USESIZE: Final = 0x2
115+
102116
STARTF_USESHOWWINDOW: Final = 0x1
103117
STARTF_USESTDHANDLES: Final = 0x100
104118

@@ -250,6 +264,20 @@ if sys.platform == "win32":
250264
def cancel(self) -> None: ...
251265
def getbuffer(self) -> bytes | None: ...
252266

267+
if sys.version_info >= (3, 13):
268+
def BatchedWaitForMultipleObjects(
269+
handle_seq: Sequence[int], wait_all: bool, milliseconds: int = 0xFFFFFFFF
270+
) -> list[int]: ...
271+
def CreateEventW(security_attributes: int, manual_reset: bool, initial_state: bool, name: str | None) -> int: ...
272+
def CreateMutexW(security_attributes: int, initial_owner: bool, name: str) -> int: ...
273+
def GetLongPathName(path: str) -> str: ...
274+
def GetShortPathName(path: str) -> str: ...
275+
def OpenEventW(desired_access: int, inherit_handle: bool, name: str) -> int: ...
276+
def OpenMutexW(desired_access: int, inherit_handle: bool, name: str) -> int: ...
277+
def ReleaseMutex(mutex: int) -> None: ...
278+
def ResetEvent(event: int) -> None: ...
279+
def SetEvent(event: int) -> None: ...
280+
253281
if sys.version_info >= (3, 12):
254282
def CopyFile2(existing_file_name: str, new_file_name: str, flags: int, progress_routine: int | None = None) -> int: ...
255283
def NeedCurrentDirectoryForExePath(exe_name: str, /) -> bool: ...

mypy/typeshed/stdlib/builtins.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# ruff: noqa: PYI036 # This is the module declaring BaseException
12
import _ast
23
import _typeshed
34
import sys

mypy/typeshed/stdlib/codecs.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class _Encoder(Protocol):
8080
def __call__(self, input: str, errors: str = ..., /) -> tuple[bytes, int]: ... # signature of Codec().encode
8181

8282
class _Decoder(Protocol):
83-
def __call__(self, input: bytes, errors: str = ..., /) -> tuple[str, int]: ... # signature of Codec().decode
83+
def __call__(self, input: ReadableBuffer, errors: str = ..., /) -> tuple[str, int]: ... # signature of Codec().decode
8484

8585
class _StreamReader(Protocol):
8686
def __call__(self, stream: _ReadableStream, errors: str = ..., /) -> StreamReader: ...

mypy/typeshed/stdlib/copy.pyi

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import sys
22
from typing import Any, Protocol, TypeVar
3-
from typing_extensions import ParamSpec, Self
3+
from typing_extensions import Self
44

55
__all__ = ["Error", "copy", "deepcopy"]
66

77
_T = TypeVar("_T")
8-
_SR = TypeVar("_SR", bound=_SupportsReplace[Any])
9-
_P = ParamSpec("_P")
8+
_SR = TypeVar("_SR", bound=_SupportsReplace)
109

11-
class _SupportsReplace(Protocol[_P]):
10+
class _SupportsReplace(Protocol):
1211
# In reality doesn't support args, but there's no other great way to express this.
13-
def __replace__(self, *args: _P.args, **kwargs: _P.kwargs) -> Self: ...
12+
def __replace__(self, *args: Any, **kwargs: Any) -> Self: ...
1413

1514
# None in CPython but non-None in Jython
1615
PyStringMap: Any

mypy/typeshed/stdlib/distutils/dist.pyi

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class Distribution:
270270
def has_data_files(self) -> bool: ...
271271
def is_pure(self) -> bool: ...
272272

273-
# Getter methods generated in __init__
273+
# Default getter methods generated in __init__ from self.metadata._METHOD_BASENAMES
274274
def get_name(self) -> str: ...
275275
def get_version(self) -> str: ...
276276
def get_fullname(self) -> str: ...
@@ -292,3 +292,26 @@ class Distribution:
292292
def get_requires(self) -> list[str]: ...
293293
def get_provides(self) -> list[str]: ...
294294
def get_obsoletes(self) -> list[str]: ...
295+
296+
# Default attributes generated in __init__ from self.display_option_names
297+
help_commands: bool | Literal[0]
298+
name: str | Literal[0]
299+
version: str | Literal[0]
300+
fullname: str | Literal[0]
301+
author: str | Literal[0]
302+
author_email: str | Literal[0]
303+
maintainer: str | Literal[0]
304+
maintainer_email: str | Literal[0]
305+
contact: str | Literal[0]
306+
contact_email: str | Literal[0]
307+
url: str | Literal[0]
308+
license: str | Literal[0]
309+
licence: str | Literal[0]
310+
description: str | Literal[0]
311+
long_description: str | Literal[0]
312+
platforms: str | list[str] | Literal[0]
313+
classifiers: str | list[str] | Literal[0]
314+
keywords: str | list[str] | Literal[0]
315+
provides: list[str] | Literal[0]
316+
requires: list[str] | Literal[0]
317+
obsoletes: list[str] | Literal[0]

mypy/typeshed/stdlib/doctest.pyi

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import sys
12
import types
23
import unittest
34
from _typeshed import ExcInfo
45
from collections.abc import Callable
5-
from typing import Any, NamedTuple
6-
from typing_extensions import TypeAlias
6+
from typing import Any, ClassVar, NamedTuple
7+
from typing_extensions import Self, TypeAlias
78

89
__all__ = [
910
"register_optionflag",
@@ -41,9 +42,22 @@ __all__ = [
4142
"debug",
4243
]
4344

44-
class TestResults(NamedTuple):
45-
failed: int
46-
attempted: int
45+
# MyPy errors on conditionals within named tuples.
46+
47+
if sys.version_info >= (3, 13):
48+
class TestResults(NamedTuple):
49+
def __new__(cls, failed: int, attempted: int, *, skipped: int = 0) -> Self: ... # type: ignore[misc]
50+
skipped: int
51+
failed: int
52+
attempted: int
53+
_fields: ClassVar = ("failed", "attempted") # type: ignore[misc]
54+
__match_args__ = ("failed", "attempted") # type: ignore[misc]
55+
__doc__: None # type: ignore[misc]
56+
57+
else:
58+
class TestResults(NamedTuple):
59+
failed: int
60+
attempted: int
4761

4862
OPTIONFLAGS_BY_NAME: dict[str, int]
4963

@@ -134,6 +148,8 @@ class DocTestRunner:
134148
original_optionflags: int
135149
tries: int
136150
failures: int
151+
if sys.version_info >= (3, 13):
152+
skips: int
137153
test: DocTest
138154
def __init__(self, checker: OutputChecker | None = None, verbose: bool | None = None, optionflags: int = 0) -> None: ...
139155
def report_start(self, out: _Out, test: DocTest, example: Example) -> None: ...

mypy/typeshed/stdlib/email/_header_value_parser.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ TOKEN_ENDS: Final[set[str]]
1616
ASPECIALS: Final[set[str]]
1717
ATTRIBUTE_ENDS: Final[set[str]]
1818
EXTENDED_ATTRIBUTE_ENDS: Final[set[str]]
19+
# Added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5
20+
NLSET: Final[set[str]]
21+
# Added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5
22+
SPECIALSNL: Final[set[str]]
1923

2024
def quote_string(value: Any) -> str: ...
2125

0 commit comments

Comments
 (0)