Skip to content

Commit 2c874f8

Browse files
author
mypybot
committed
Sync typeshed
Source commit: python/typeshed@5a3c495
1 parent 68233f6 commit 2c874f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+883
-257
lines changed

mypy/typeshed/stdlib/_asyncio.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
from asyncio.events import AbstractEventLoop
3-
from collections.abc import Awaitable, Callable, Coroutine, Generator, Iterable
3+
from collections.abc import Awaitable, Callable, Coroutine, Generator
44
from contextvars import Context
55
from types import FrameType, GenericAlias
66
from typing import Any, Literal, TextIO, TypeVar
@@ -10,7 +10,7 @@ _T = TypeVar("_T")
1010
_T_co = TypeVar("_T_co", covariant=True)
1111
_TaskYieldType: TypeAlias = Future[object] | None
1212

13-
class Future(Awaitable[_T], Iterable[_T]):
13+
class Future(Awaitable[_T]):
1414
_state: str
1515
@property
1616
def _exception(self) -> BaseException | None: ...
@@ -107,3 +107,4 @@ if sys.version_info >= (3, 12):
107107
if sys.version_info >= (3, 14):
108108
def future_discard_from_awaited_by(future: Future[Any], waiter: Future[Any], /) -> None: ...
109109
def future_add_to_awaited_by(future: Future[Any], waiter: Future[Any], /) -> None: ...
110+
def all_tasks(loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ...

mypy/typeshed/stdlib/_ctypes.pyi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class _CData:
7575
_objects: Mapping[Any, int] | None
7676
def __buffer__(self, flags: int, /) -> memoryview: ...
7777
def __ctypes_from_outparam__(self, /) -> Self: ...
78+
if sys.version_info >= (3, 14):
79+
__pointer_type__: type
7880

7981
# this is a union of all the subclasses of _CData, which is useful because of
8082
# the methods that are present on each of those subclasses which are not present
@@ -289,7 +291,11 @@ class Array(_CData, Generic[_CT], metaclass=_PyCArrayType):
289291
def _type_(self) -> type[_CT]: ...
290292
@_type_.setter
291293
def _type_(self, value: type[_CT]) -> None: ...
292-
raw: bytes # Note: only available if _CT == c_char
294+
# Note: only available if _CT == c_char
295+
@property
296+
def raw(self) -> bytes: ...
297+
@raw.setter
298+
def raw(self, value: ReadableBuffer) -> None: ...
293299
value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise
294300
# TODO: These methods cannot be annotated correctly at the moment.
295301
# All of these "Any"s stand for the array's element type, but it's not possible to use _CT

mypy/typeshed/stdlib/_curses.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ def has_colors() -> bool: ...
304304
if sys.version_info >= (3, 10):
305305
def has_extended_color_support() -> bool: ...
306306

307+
if sys.version_info >= (3, 14):
308+
def assume_default_colors(fg: int, bg: int, /) -> None: ...
309+
307310
def has_ic() -> bool: ...
308311
def has_il() -> bool: ...
309312
def has_key(key: int, /) -> bool: ...

mypy/typeshed/stdlib/_heapq.pyi

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
import sys
12
from typing import Any, Final, TypeVar
23

3-
_T = TypeVar("_T")
4+
_T = TypeVar("_T") # list items must be comparable
45

56
__about__: Final[str]
67

7-
def heapify(heap: list[Any], /) -> None: ...
8+
def heapify(heap: list[Any], /) -> None: ... # list items must be comparable
89
def heappop(heap: list[_T], /) -> _T: ...
910
def heappush(heap: list[_T], item: _T, /) -> None: ...
1011
def heappushpop(heap: list[_T], item: _T, /) -> _T: ...
1112
def heapreplace(heap: list[_T], item: _T, /) -> _T: ...
13+
14+
if sys.version_info >= (3, 14):
15+
def heapify_max(heap: list[Any], /) -> None: ... # list items must be comparable
16+
def heappop_max(heap: list[_T], /) -> _T: ...
17+
def heappush_max(heap: list[_T], item: _T, /) -> None: ...
18+
def heappushpop_max(heap: list[_T], item: _T, /) -> _T: ...
19+
def heapreplace_max(heap: list[_T], item: _T, /) -> _T: ...

mypy/typeshed/stdlib/_imp.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ from importlib.machinery import ModuleSpec
55
from typing import Any
66

77
check_hash_based_pycs: str
8+
if sys.version_info >= (3, 14):
9+
pyc_magic_number_token: int
810

911
def source_hash(key: int, source: ReadableBuffer) -> bytes: ...
1012
def create_builtin(spec: ModuleSpec, /) -> types.ModuleType: ...

mypy/typeshed/stdlib/_posixsubprocess.pyi

Lines changed: 53 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,56 @@ from collections.abc import Callable, Sequence
44
from typing import SupportsIndex
55

66
if sys.platform != "win32":
7-
def fork_exec(
8-
args: Sequence[StrOrBytesPath] | None,
9-
executable_list: Sequence[bytes],
10-
close_fds: bool,
11-
pass_fds: tuple[int, ...],
12-
cwd: str,
13-
env: Sequence[bytes] | None,
14-
p2cread: int,
15-
p2cwrite: int,
16-
c2pread: int,
17-
c2pwrite: int,
18-
errread: int,
19-
errwrite: int,
20-
errpipe_read: int,
21-
errpipe_write: int,
22-
restore_signals: int,
23-
call_setsid: int,
24-
pgid_to_set: int,
25-
gid: SupportsIndex | None,
26-
extra_groups: list[int] | None,
27-
uid: SupportsIndex | None,
28-
child_umask: int,
29-
preexec_fn: Callable[[], None],
30-
allow_vfork: bool,
31-
/,
32-
) -> int: ...
7+
if sys.version_info >= (3, 14):
8+
def fork_exec(
9+
args: Sequence[StrOrBytesPath] | None,
10+
executable_list: Sequence[bytes],
11+
close_fds: bool,
12+
pass_fds: tuple[int, ...],
13+
cwd: str,
14+
env: Sequence[bytes] | None,
15+
p2cread: int,
16+
p2cwrite: int,
17+
c2pread: int,
18+
c2pwrite: int,
19+
errread: int,
20+
errwrite: int,
21+
errpipe_read: int,
22+
errpipe_write: int,
23+
restore_signals: int,
24+
call_setsid: int,
25+
pgid_to_set: int,
26+
gid: SupportsIndex | None,
27+
extra_groups: list[int] | None,
28+
uid: SupportsIndex | None,
29+
child_umask: int,
30+
preexec_fn: Callable[[], None],
31+
/,
32+
) -> int: ...
33+
else:
34+
def fork_exec(
35+
args: Sequence[StrOrBytesPath] | None,
36+
executable_list: Sequence[bytes],
37+
close_fds: bool,
38+
pass_fds: tuple[int, ...],
39+
cwd: str,
40+
env: Sequence[bytes] | None,
41+
p2cread: int,
42+
p2cwrite: int,
43+
c2pread: int,
44+
c2pwrite: int,
45+
errread: int,
46+
errwrite: int,
47+
errpipe_read: int,
48+
errpipe_write: int,
49+
restore_signals: bool,
50+
call_setsid: bool,
51+
pgid_to_set: int,
52+
gid: SupportsIndex | None,
53+
extra_groups: list[int] | None,
54+
uid: SupportsIndex | None,
55+
child_umask: int,
56+
preexec_fn: Callable[[], None],
57+
allow_vfork: bool,
58+
/,
59+
) -> int: ...

mypy/typeshed/stdlib/_thread.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class RLock:
1818
def release(self) -> None: ...
1919
__enter__ = acquire
2020
def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
21+
if sys.version_info >= (3, 14):
22+
def locked(self) -> bool: ...
2123

2224
if sys.version_info >= (3, 13):
2325
@final
@@ -105,6 +107,9 @@ _excepthook: Callable[[_ExceptHookArgs], Any]
105107
if sys.version_info >= (3, 12):
106108
def daemon_threads_allowed() -> bool: ...
107109

110+
if sys.version_info >= (3, 14):
111+
def set_name(name: str) -> None: ...
112+
108113
class _local:
109114
def __getattribute__(self, name: str, /) -> Any: ...
110115
def __setattr__(self, name: str, value: Any, /) -> None: ...

mypy/typeshed/stdlib/_tkinter.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class TkappType:
7777
def globalgetvar(self, *args, **kwargs): ...
7878
def globalsetvar(self, *args, **kwargs): ...
7979
def globalunsetvar(self, *args, **kwargs): ...
80-
def interpaddr(self): ...
80+
def interpaddr(self) -> int: ...
8181
def loadtk(self) -> None: ...
8282
def mainloop(self, threshold: int = 0, /): ...
8383
def quit(self): ...

mypy/typeshed/stdlib/_typeshed/__init__.pyi

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,6 @@ class SupportsGetItemBuffer(SliceableBuffer, IndexableBuffer, Protocol):
298298

299299
class SizedBuffer(Sized, Buffer, Protocol): ...
300300

301-
# for compatibility with third-party stubs that may use this
302-
_BufferWithLen: TypeAlias = SizedBuffer # not stable # noqa: Y047
303-
304301
ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType]
305302
OptExcInfo: TypeAlias = ExcInfo | tuple[None, None, None]
306303

mypy/typeshed/stdlib/argparse.pyi

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import sys
22
from _typeshed import SupportsWrite, sentinel
33
from collections.abc import Callable, Generator, Iterable, Sequence
44
from re import Pattern
5-
from typing import IO, Any, ClassVar, Final, Generic, NewType, NoReturn, Protocol, TypeVar, overload
5+
from typing import IO, Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeVar, overload
66
from typing_extensions import Self, TypeAlias, deprecated
77

88
__all__ = [
@@ -36,9 +36,7 @@ ONE_OR_MORE: Final = "+"
3636
OPTIONAL: Final = "?"
3737
PARSER: Final = "A..."
3838
REMAINDER: Final = "..."
39-
_SUPPRESS_T = NewType("_SUPPRESS_T", str)
40-
SUPPRESS: _SUPPRESS_T | str # not using Literal because argparse sometimes compares SUPPRESS with is
41-
# the | str is there so that foo = argparse.SUPPRESS; foo = "test" checks out in mypy
39+
SUPPRESS: Final = "==SUPPRESS=="
4240
ZERO_OR_MORE: Final = "*"
4341
_UNRECOGNIZED_ARGS_ATTR: Final = "_unrecognized_args" # undocumented
4442

@@ -81,7 +79,7 @@ class _ActionsContainer:
8179
# more precisely, Literal["?", "*", "+", "...", "A...", "==SUPPRESS=="],
8280
# but using this would make it hard to annotate callers that don't use a
8381
# literal argument and for subclasses to override this method.
84-
nargs: int | str | _SUPPRESS_T | None = None,
82+
nargs: int | str | None = None,
8583
const: Any = ...,
8684
default: Any = ...,
8785
type: _ActionType = ...,
@@ -283,13 +281,7 @@ class HelpFormatter:
283281

284282
if sys.version_info >= (3, 14):
285283
def __init__(
286-
self,
287-
prog: str,
288-
indent_increment: int = 2,
289-
max_help_position: int = 24,
290-
width: int | None = None,
291-
prefix_chars: str = "-",
292-
color: bool = False,
284+
self, prog: str, indent_increment: int = 2, max_help_position: int = 24, width: int | None = None, color: bool = False
293285
) -> None: ...
294286
else:
295287
def __init__(

mypy/typeshed/stdlib/ast.pyi

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,20 +1095,28 @@ if sys.version_info >= (3, 14):
10951095
**kwargs: Unpack[_Attributes],
10961096
) -> Self: ...
10971097

1098+
if sys.version_info >= (3, 10):
1099+
from types import EllipsisType
1100+
1101+
_ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | int | float | complex | None | EllipsisType
1102+
else:
1103+
# Rely on builtins.ellipsis
1104+
_ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | int | float | complex | None | ellipsis # noqa: F821
1105+
10981106
class Constant(expr):
10991107
if sys.version_info >= (3, 10):
11001108
__match_args__ = ("value", "kind")
1101-
value: Any # None, str, bytes, bool, int, float, complex, Ellipsis
1109+
value: _ConstantValue
11021110
kind: str | None
11031111
if sys.version_info < (3, 14):
11041112
# Aliases for value, for backwards compatibility
1105-
s: Any
1106-
n: int | float | complex
1113+
s: _ConstantValue
1114+
n: _ConstantValue
11071115

1108-
def __init__(self, value: Any, kind: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
1116+
def __init__(self, value: _ConstantValue, kind: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
11091117

11101118
if sys.version_info >= (3, 14):
1111-
def __replace__(self, *, value: Any = ..., kind: str | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
1119+
def __replace__(self, *, value: _ConstantValue = ..., kind: str | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
11121120

11131121
class Attribute(expr):
11141122
if sys.version_info >= (3, 10):
@@ -1429,15 +1437,19 @@ class keyword(AST):
14291437
def __replace__(self, *, arg: str | None = ..., value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
14301438

14311439
class alias(AST):
1432-
lineno: int
1433-
col_offset: int
1434-
end_lineno: int | None
1435-
end_col_offset: int | None
1436-
if sys.version_info >= (3, 10):
1437-
__match_args__ = ("name", "asname")
14381440
name: str
14391441
asname: str | None
1440-
def __init__(self, name: str, asname: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
1442+
if sys.version_info >= (3, 10):
1443+
lineno: int
1444+
col_offset: int
1445+
end_lineno: int | None
1446+
end_col_offset: int | None
1447+
if sys.version_info >= (3, 10):
1448+
__match_args__ = ("name", "asname")
1449+
if sys.version_info >= (3, 10):
1450+
def __init__(self, name: str, asname: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
1451+
else:
1452+
def __init__(self, name: str, asname: str | None = None) -> None: ...
14411453

14421454
if sys.version_info >= (3, 14):
14431455
def __replace__(self, *, name: str = ..., asname: str | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ...

mypy/typeshed/stdlib/asyncio/__init__.pyi

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ if sys.platform == "win32":
4141
"Server", # from base_events
4242
"iscoroutinefunction", # from coroutines
4343
"iscoroutine", # from coroutines
44-
"AbstractEventLoopPolicy", # from events
44+
"_AbstractEventLoopPolicy", # from events
4545
"AbstractEventLoop", # from events
4646
"AbstractServer", # from events
4747
"Handle", # from events
4848
"TimerHandle", # from events
49+
"_get_event_loop_policy", # from events
4950
"get_event_loop_policy", # from events
51+
"_set_event_loop_policy", # from events
5052
"set_event_loop_policy", # from events
5153
"get_event_loop", # from events
5254
"set_event_loop", # from events
@@ -132,9 +134,9 @@ if sys.platform == "win32":
132134
"SelectorEventLoop", # from windows_events
133135
"ProactorEventLoop", # from windows_events
134136
"IocpProactor", # from windows_events
135-
"DefaultEventLoopPolicy", # from windows_events
136-
"WindowsSelectorEventLoopPolicy", # from windows_events
137-
"WindowsProactorEventLoopPolicy", # from windows_events
137+
"_DefaultEventLoopPolicy", # from windows_events
138+
"_WindowsSelectorEventLoopPolicy", # from windows_events
139+
"_WindowsProactorEventLoopPolicy", # from windows_events
138140
"EventLoop", # from windows_events
139141
)
140142
elif sys.version_info >= (3, 13):
@@ -515,12 +517,14 @@ else:
515517
"Server", # from base_events
516518
"iscoroutinefunction", # from coroutines
517519
"iscoroutine", # from coroutines
518-
"AbstractEventLoopPolicy", # from events
520+
"_AbstractEventLoopPolicy", # from events
519521
"AbstractEventLoop", # from events
520522
"AbstractServer", # from events
521523
"Handle", # from events
522524
"TimerHandle", # from events
525+
"_get_event_loop_policy", # from events
523526
"get_event_loop_policy", # from events
527+
"_set_event_loop_policy", # from events
524528
"set_event_loop_policy", # from events
525529
"get_event_loop", # from events
526530
"set_event_loop", # from events
@@ -606,7 +610,7 @@ else:
606610
"DatagramTransport", # from transports
607611
"SubprocessTransport", # from transports
608612
"SelectorEventLoop", # from unix_events
609-
"DefaultEventLoopPolicy", # from unix_events
613+
"_DefaultEventLoopPolicy", # from unix_events
610614
"EventLoop", # from unix_events
611615
)
612616
elif sys.version_info >= (3, 13):

0 commit comments

Comments
 (0)