Skip to content

Commit 6e37560

Browse files
mypybothauntsaninja
authored andcommitted
Sync typeshed
Source commit: python/typeshed@f863db6
1 parent b202f30 commit 6e37560

Some content is hidden

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

53 files changed

+995
-225
lines changed

mypy/typeshed/stdlib/VERSIONS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ _dummy_threading: 3.0-3.8
3535
_heapq: 3.0-
3636
_imp: 3.0-
3737
_interpchannels: 3.13-
38+
_interpqueues: 3.13-
39+
_interpreters: 3.13-
3840
_json: 3.0-
3941
_locale: 3.0-
4042
_lsprof: 3.0-
@@ -112,6 +114,7 @@ curses: 3.0-
112114
dataclasses: 3.7-
113115
datetime: 3.0-
114116
dbm: 3.0-
117+
dbm.sqlite3: 3.13-
115118
decimal: 3.0-
116119
difflib: 3.0-
117120
dis: 3.0-
@@ -155,6 +158,7 @@ importlib: 3.0-
155158
importlib._abc: 3.10-
156159
importlib.metadata: 3.8-
157160
importlib.metadata._meta: 3.10-
161+
importlib.metadata.diagnose: 3.13-
158162
importlib.readers: 3.10-
159163
importlib.resources: 3.7-
160164
importlib.resources.abc: 3.11-

mypy/typeshed/stdlib/_collections_abc.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ _VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers.
7070
@final
7171
class dict_keys(KeysView[_KT_co], Generic[_KT_co, _VT_co]): # undocumented
7272
def __eq__(self, value: object, /) -> bool: ...
73+
if sys.version_info >= (3, 13):
74+
def isdisjoint(self, other: Iterable[_KT_co], /) -> bool: ...
7375
if sys.version_info >= (3, 10):
7476
@property
7577
def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ...
@@ -83,6 +85,8 @@ class dict_values(ValuesView[_VT_co], Generic[_KT_co, _VT_co]): # undocumented
8385
@final
8486
class dict_items(ItemsView[_KT_co, _VT_co]): # undocumented
8587
def __eq__(self, value: object, /) -> bool: ...
88+
if sys.version_info >= (3, 13):
89+
def isdisjoint(self, other: Iterable[tuple[_KT_co, _VT_co]], /) -> bool: ...
8690
if sys.version_info >= (3, 10):
8791
@property
8892
def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ...

mypy/typeshed/stdlib/_ctypes.pyi

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ class _CData(metaclass=_CDataMeta):
6464
# Structure.from_buffer(...) # valid at runtime
6565
# Structure(...).from_buffer(...) # invalid at runtime
6666
#
67-
6867
@classmethod
6968
def from_buffer(cls, source: WriteableBuffer, offset: int = ...) -> Self: ...
7069
@classmethod
@@ -100,8 +99,8 @@ class _Pointer(_PointerLike, _CData, Generic[_CT]):
10099
def __getitem__(self, key: slice, /) -> list[Any]: ...
101100
def __setitem__(self, key: int, value: Any, /) -> None: ...
102101

103-
def POINTER(type: type[_CT]) -> type[_Pointer[_CT]]: ...
104-
def pointer(arg: _CT, /) -> _Pointer[_CT]: ...
102+
def POINTER(type: type[_CT], /) -> type[_Pointer[_CT]]: ...
103+
def pointer(obj: _CT, /) -> _Pointer[_CT]: ...
105104

106105
class _CArgObject: ...
107106

@@ -169,7 +168,11 @@ class Array(_CData, Generic[_CT]):
169168
def _type_(self) -> type[_CT]: ...
170169
@_type_.setter
171170
def _type_(self, value: type[_CT]) -> None: ...
172-
raw: bytes # Note: only available if _CT == c_char
171+
# Note: only available if _CT == c_char
172+
@property
173+
def raw(self) -> bytes: ...
174+
@raw.setter
175+
def raw(self, value: ReadableBuffer) -> None: ...
173176
value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise
174177
# TODO These methods cannot be annotated correctly at the moment.
175178
# All of these "Any"s stand for the array's element type, but it's not possible to use _CT
@@ -199,9 +202,9 @@ class Array(_CData, Generic[_CT]):
199202
if sys.version_info >= (3, 9):
200203
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
201204

202-
def addressof(obj: _CData) -> int: ...
203-
def alignment(obj_or_type: _CData | type[_CData]) -> int: ...
205+
def addressof(obj: _CData, /) -> int: ...
206+
def alignment(obj_or_type: _CData | type[_CData], /) -> int: ...
204207
def get_errno() -> int: ...
205-
def resize(obj: _CData, size: int) -> None: ...
206-
def set_errno(value: int) -> int: ...
207-
def sizeof(obj_or_type: _CData | type[_CData]) -> int: ...
208+
def resize(obj: _CData, size: int, /) -> None: ...
209+
def set_errno(value: int, /) -> int: ...
210+
def sizeof(obj_or_type: _CData | type[_CData], /) -> int: ...
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from typing import Any, SupportsIndex
2+
3+
class QueueError(RuntimeError): ...
4+
class QueueNotFoundError(QueueError): ...
5+
6+
def bind(qid: SupportsIndex) -> None: ...
7+
def create(maxsize: SupportsIndex, fmt: SupportsIndex) -> int: ...
8+
def destroy(qid: SupportsIndex) -> None: ...
9+
def get(qid: SupportsIndex) -> tuple[Any, int]: ...
10+
def get_count(qid: SupportsIndex) -> int: ...
11+
def get_maxsize(qid: SupportsIndex) -> int: ...
12+
def get_queue_defaults(qid: SupportsIndex) -> tuple[int]: ...
13+
def is_full(qid: SupportsIndex) -> bool: ...
14+
def list_all() -> list[tuple[int, int]]: ...
15+
def put(qid: SupportsIndex, obj: Any, fmt: SupportsIndex) -> None: ...
16+
def release(qid: SupportsIndex) -> None: ...
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import types
2+
from collections.abc import Callable, Mapping
3+
from typing import Final, Literal, SupportsIndex
4+
from typing_extensions import TypeAlias
5+
6+
_Configs: TypeAlias = Literal["default", "isolated", "legacy", "empty", ""]
7+
8+
class InterpreterError(Exception): ...
9+
class InterpreterNotFoundError(InterpreterError): ...
10+
class NotShareableError(Exception): ...
11+
12+
class CrossInterpreterBufferView:
13+
def __buffer__(self, flags: int, /) -> memoryview: ...
14+
15+
def new_config(name: _Configs = "isolated", /, **overides: object) -> types.SimpleNamespace: ...
16+
def create(config: types.SimpleNamespace | _Configs | None = "isolated", *, reqrefs: bool = False) -> int: ...
17+
def destroy(id: SupportsIndex, *, restrict: bool = False) -> None: ...
18+
def list_all(*, require_ready: bool) -> list[tuple[int, int]]: ...
19+
def get_current() -> tuple[int, int]: ...
20+
def get_main() -> tuple[int, int]: ...
21+
def is_running(id: SupportsIndex, *, restrict: bool = False) -> bool: ...
22+
def get_config(id: SupportsIndex, *, restrict: bool = False) -> types.SimpleNamespace: ...
23+
def whence(id: SupportsIndex) -> int: ...
24+
def exec(id: SupportsIndex, code: str, shared: bool | None = None, *, restrict: bool = False) -> None: ...
25+
def call(
26+
id: SupportsIndex,
27+
callable: Callable[..., object],
28+
args: tuple[object, ...] | None = None,
29+
kwargs: dict[str, object] | None = None,
30+
*,
31+
restrict: bool = False,
32+
) -> object: ...
33+
def run_string(
34+
id: SupportsIndex, script: str | types.CodeType | Callable[[], object], shared: bool | None = None, *, restrict: bool = False
35+
) -> None: ...
36+
def run_func(
37+
id: SupportsIndex, func: types.CodeType | Callable[[], object], shared: bool | None = None, *, restrict: bool = False
38+
) -> None: ...
39+
def set___main___attrs(id: SupportsIndex, updates: Mapping[str, object], *, restrict: bool = False) -> None: ...
40+
def incref(id: SupportsIndex, *, implieslink: bool = False, restrict: bool = False) -> None: ...
41+
def decref(id: SupportsIndex, *, restrict: bool = False) -> None: ...
42+
def is_shareable(obj: object) -> bool: ...
43+
def capture_exception(exc: BaseException | None = None) -> types.SimpleNamespace: ...
44+
45+
WHENCE_UNKNOWN: Final = 0
46+
WHENCE_RUNTIME: Final = 1
47+
WHENCE_LEGACY_CAPI: Final = 2
48+
WHENCE_CAPI: Final = 3
49+
WHENCE_XI: Final = 4
50+
WHENCE_STDLIB: Final = 5

mypy/typeshed/stdlib/_thread.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ error = RuntimeError
1313
def _count() -> int: ...
1414
@final
1515
class LockType:
16-
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
16+
def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ...
1717
def release(self) -> None: ...
1818
def locked(self) -> bool: ...
1919
def __enter__(self) -> bool: ...
@@ -22,14 +22,14 @@ class LockType:
2222
) -> None: ...
2323

2424
@overload
25-
def start_new_thread(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]]) -> int: ...
25+
def start_new_thread(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]], /) -> int: ...
2626
@overload
27-
def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any]) -> int: ...
27+
def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ...
2828
def interrupt_main() -> None: ...
2929
def exit() -> NoReturn: ...
3030
def allocate_lock() -> LockType: ...
3131
def get_ident() -> int: ...
32-
def stack_size(size: int = ...) -> int: ...
32+
def stack_size(size: int = 0, /) -> int: ...
3333

3434
TIMEOUT_MAX: float
3535

mypy/typeshed/stdlib/abc.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ class ABCMeta(type):
2828
def register(cls: ABCMeta, subclass: type[_T]) -> type[_T]: ...
2929

3030
def abstractmethod(funcobj: _FuncT) -> _FuncT: ...
31-
@deprecated("Deprecated, use 'classmethod' with 'abstractmethod' instead")
31+
@deprecated("Use 'classmethod' with 'abstractmethod' instead")
3232
class abstractclassmethod(classmethod[_T, _P, _R_co]):
3333
__isabstractmethod__: Literal[True]
3434
def __init__(self, callable: Callable[Concatenate[type[_T], _P], _R_co]) -> None: ...
3535

36-
@deprecated("Deprecated, use 'staticmethod' with 'abstractmethod' instead")
36+
@deprecated("Use 'staticmethod' with 'abstractmethod' instead")
3737
class abstractstaticmethod(staticmethod[_P, _R_co]):
3838
__isabstractmethod__: Literal[True]
3939
def __init__(self, callable: Callable[_P, _R_co]) -> None: ...
4040

41-
@deprecated("Deprecated, use 'property' with 'abstractmethod' instead")
41+
@deprecated("Use 'property' with 'abstractmethod' instead")
4242
class abstractproperty(property):
4343
__isabstractmethod__: Literal[True]
4444

mypy/typeshed/stdlib/asyncio/base_events.pyi

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ class Server(AbstractServer):
4949
ssl_handshake_timeout: float | None,
5050
) -> None: ...
5151

52+
if sys.version_info >= (3, 13):
53+
def close_clients(self) -> None: ...
54+
def abort_clients(self) -> None: ...
55+
5256
def get_loop(self) -> AbstractEventLoop: ...
5357
def is_serving(self) -> bool: ...
5458
async def start_serving(self) -> None: ...
@@ -222,7 +226,9 @@ class BaseEventLoop(AbstractEventLoop):
222226
happy_eyeballs_delay: float | None = None,
223227
interleave: int | None = None,
224228
) -> tuple[Transport, _ProtocolT]: ...
225-
if sys.version_info >= (3, 11):
229+
230+
if sys.version_info >= (3, 13):
231+
# 3.13 added `keep_alive`.
226232
@overload
227233
async def create_server(
228234
self,
@@ -237,6 +243,7 @@ class BaseEventLoop(AbstractEventLoop):
237243
ssl: _SSLContext = None,
238244
reuse_address: bool | None = None,
239245
reuse_port: bool | None = None,
246+
keep_alive: bool | None = None,
240247
ssl_handshake_timeout: float | None = None,
241248
ssl_shutdown_timeout: float | None = None,
242249
start_serving: bool = True,
@@ -255,30 +262,48 @@ class BaseEventLoop(AbstractEventLoop):
255262
ssl: _SSLContext = None,
256263
reuse_address: bool | None = None,
257264
reuse_port: bool | None = None,
265+
keep_alive: bool | None = None,
258266
ssl_handshake_timeout: float | None = None,
259267
ssl_shutdown_timeout: float | None = None,
260268
start_serving: bool = True,
261269
) -> Server: ...
262-
async def start_tls(
270+
elif sys.version_info >= (3, 11):
271+
@overload
272+
async def create_server(
263273
self,
264-
transport: BaseTransport,
265-
protocol: BaseProtocol,
266-
sslcontext: ssl.SSLContext,
274+
protocol_factory: _ProtocolFactory,
275+
host: str | Sequence[str] | None = None,
276+
port: int = ...,
267277
*,
268-
server_side: bool = False,
269-
server_hostname: str | None = None,
278+
family: int = ...,
279+
flags: int = ...,
280+
sock: None = None,
281+
backlog: int = 100,
282+
ssl: _SSLContext = None,
283+
reuse_address: bool | None = None,
284+
reuse_port: bool | None = None,
270285
ssl_handshake_timeout: float | None = None,
271286
ssl_shutdown_timeout: float | None = None,
272-
) -> Transport | None: ...
273-
async def connect_accepted_socket(
287+
start_serving: bool = True,
288+
) -> Server: ...
289+
@overload
290+
async def create_server(
274291
self,
275-
protocol_factory: Callable[[], _ProtocolT],
276-
sock: socket,
292+
protocol_factory: _ProtocolFactory,
293+
host: None = None,
294+
port: None = None,
277295
*,
296+
family: int = ...,
297+
flags: int = ...,
298+
sock: socket = ...,
299+
backlog: int = 100,
278300
ssl: _SSLContext = None,
301+
reuse_address: bool | None = None,
302+
reuse_port: bool | None = None,
279303
ssl_handshake_timeout: float | None = None,
280304
ssl_shutdown_timeout: float | None = None,
281-
) -> tuple[Transport, _ProtocolT]: ...
305+
start_serving: bool = True,
306+
) -> Server: ...
282307
else:
283308
@overload
284309
async def create_server(
@@ -314,6 +339,29 @@ class BaseEventLoop(AbstractEventLoop):
314339
ssl_handshake_timeout: float | None = None,
315340
start_serving: bool = True,
316341
) -> Server: ...
342+
343+
if sys.version_info >= (3, 11):
344+
async def start_tls(
345+
self,
346+
transport: BaseTransport,
347+
protocol: BaseProtocol,
348+
sslcontext: ssl.SSLContext,
349+
*,
350+
server_side: bool = False,
351+
server_hostname: str | None = None,
352+
ssl_handshake_timeout: float | None = None,
353+
ssl_shutdown_timeout: float | None = None,
354+
) -> Transport | None: ...
355+
async def connect_accepted_socket(
356+
self,
357+
protocol_factory: Callable[[], _ProtocolT],
358+
sock: socket,
359+
*,
360+
ssl: _SSLContext = None,
361+
ssl_handshake_timeout: float | None = None,
362+
ssl_shutdown_timeout: float | None = None,
363+
) -> tuple[Transport, _ProtocolT]: ...
364+
else:
317365
async def start_tls(
318366
self,
319367
transport: BaseTransport,

0 commit comments

Comments
 (0)