Skip to content

Commit 8407149

Browse files
Add Python 3.15 JSON and sqlite3 updates (#15732)
Co-authored-by: Sebastian Rittau <sebastian.rittau@zfutura.de>
1 parent f74b24b commit 8407149

7 files changed

Lines changed: 122 additions & 55 deletions

File tree

stdlib/@tests/stubtest_allowlists/py315.txt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ _frozen_importlib_external._LoaderBasics.load_module
1414
_frozen_importlib_external.cache_from_source
1515
_interpqueues.create
1616
_interpqueues.put
17-
_json.make_scanner.array_hook
18-
_json.scanstring
1917
_pyrepl.base_eventqueue
2018
_pyrepl.commands
2119
_pyrepl.completing_reader
@@ -38,7 +36,6 @@ _pyrepl.types
3836
_pyrepl.utils
3937
_pyrepl.windows_console
4038
_pyrepl.windows_eventqueue
41-
_sqlite3.SQLITE_KEYWORDS
4239
_ssl.HAS_PSK_TLS13
4340
_ssl._SSLContext.get_groups
4441
_ssl._SSLContext.set_ciphersuites
@@ -182,9 +179,6 @@ io.Reader.__class_getitem__
182179
io.Reader.read
183180
io.Writer.__class_getitem__
184181
io.Writer.write
185-
json.decoder.JSONDecoder.__init__
186-
json.load
187-
json.loads
188182
mailbox.Mailbox.__enter__
189183
mailbox.Mailbox.__exit__
190184
mailbox._ProxyFile.__class_getitem__
@@ -278,13 +272,6 @@ site.addsitedir
278272
site.addsitepackages
279273
site.addusersitepackages
280274
site.process_startup_files
281-
sqlite3.Connection.create_aggregate
282-
sqlite3.Connection.create_function
283-
sqlite3.Connection.set_authorizer
284-
sqlite3.Connection.set_progress_handler
285-
sqlite3.Connection.set_trace_callback
286-
sqlite3.SQLITE_KEYWORDS
287-
sqlite3.dbapi2.SQLITE_KEYWORDS
288275
sre_compile
289276
sre_constants
290277
sre_parse

stdlib/_json.pyi

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from collections.abc import Callable
23
from typing import Any, final
34
from typing_extensions import Self
@@ -36,6 +37,8 @@ class make_encoder:
3637

3738
@final
3839
class make_scanner:
40+
if sys.version_info >= (3, 15):
41+
array_hook: Any
3942
object_hook: Any
4043
object_pairs_hook: Any
4144
parse_int: Any
@@ -48,4 +51,9 @@ class make_scanner:
4851

4952
def encode_basestring(s: str, /) -> str: ...
5053
def encode_basestring_ascii(s: str, /) -> str: ...
51-
def scanstring(string: str, end: int, strict: bool = True) -> tuple[str, int]: ...
54+
55+
if sys.version_info >= (3, 15):
56+
def scanstring(pystr: str, end: int, strict: bool = True, /) -> tuple[str, int]: ...
57+
58+
else:
59+
def scanstring(string: str, end: int, strict: bool = True) -> tuple[str, int]: ...

stdlib/_sqlite3.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ SQLITE_SAVEPOINT: Final = 32
6969
SQLITE_SELECT: Final = 21
7070
SQLITE_TRANSACTION: Final = 22
7171
SQLITE_UPDATE: Final = 23
72+
if sys.version_info >= (3, 15):
73+
SQLITE_KEYWORDS: tuple[str, ...]
7274
adapters: dict[tuple[type[Any], type[Any]], _Adapter[Any]]
7375
converters: dict[str, _Converter]
7476
sqlite_version: str

stdlib/json/__init__.pyi

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from _typeshed import SupportsRead, SupportsWrite
23
from collections.abc import Callable
34
from typing import Any, Literal
@@ -36,28 +37,57 @@ def dump(
3637
sort_keys: bool = False,
3738
**kwds: Any,
3839
) -> None: ...
39-
def loads(
40-
s: str | bytes | bytearray,
41-
*,
42-
cls: type[JSONDecoder] | None = None,
43-
object_hook: Callable[[dict[Any, Any]], Any] | None = None,
44-
parse_float: Callable[[str], Any] | None = None,
45-
parse_int: Callable[[str], Any] | None = None,
46-
parse_constant: Callable[[str], Any] | None = None,
47-
object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
48-
**kwds: Any,
49-
) -> Any: ...
50-
def load(
51-
fp: SupportsRead[str | bytes],
52-
*,
53-
cls: type[JSONDecoder] | None = None,
54-
object_hook: Callable[[dict[Any, Any]], Any] | None = None,
55-
parse_float: Callable[[str], Any] | None = None,
56-
parse_int: Callable[[str], Any] | None = None,
57-
parse_constant: Callable[[str], Any] | None = None,
58-
object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
59-
**kwds: Any,
60-
) -> Any: ...
40+
41+
if sys.version_info >= (3, 15):
42+
def loads(
43+
s: str | bytes | bytearray,
44+
*,
45+
cls: type[JSONDecoder] | None = None,
46+
object_hook: Callable[[dict[Any, Any]], Any] | None = None,
47+
parse_float: Callable[[str], Any] | None = None,
48+
parse_int: Callable[[str], Any] | None = None,
49+
parse_constant: Callable[[str], Any] | None = None,
50+
object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
51+
array_hook: Callable[[list[Any]], Any] | None = None,
52+
**kwds: Any,
53+
) -> Any: ...
54+
def load(
55+
fp: SupportsRead[str | bytes],
56+
*,
57+
cls: type[JSONDecoder] | None = None,
58+
object_hook: Callable[[dict[Any, Any]], Any] | None = None,
59+
parse_float: Callable[[str], Any] | None = None,
60+
parse_int: Callable[[str], Any] | None = None,
61+
parse_constant: Callable[[str], Any] | None = None,
62+
object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
63+
array_hook: Callable[[list[Any]], Any] | None = None,
64+
**kwds: Any,
65+
) -> Any: ...
66+
67+
else:
68+
def loads(
69+
s: str | bytes | bytearray,
70+
*,
71+
cls: type[JSONDecoder] | None = None,
72+
object_hook: Callable[[dict[Any, Any]], Any] | None = None,
73+
parse_float: Callable[[str], Any] | None = None,
74+
parse_int: Callable[[str], Any] | None = None,
75+
parse_constant: Callable[[str], Any] | None = None,
76+
object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
77+
**kwds: Any,
78+
) -> Any: ...
79+
def load(
80+
fp: SupportsRead[str | bytes],
81+
*,
82+
cls: type[JSONDecoder] | None = None,
83+
object_hook: Callable[[dict[Any, Any]], Any] | None = None,
84+
parse_float: Callable[[str], Any] | None = None,
85+
parse_int: Callable[[str], Any] | None = None,
86+
parse_constant: Callable[[str], Any] | None = None,
87+
object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
88+
**kwds: Any,
89+
) -> Any: ...
90+
6191
def detect_encoding(
6292
b: bytes | bytearray,
6393
) -> Literal["utf-8", "utf-8-sig", "utf-16", "utf-16-be", "utf-16-le", "utf-32", "utf-32-be", "utf-32-le"]: ... # undocumented

stdlib/json/decoder.pyi

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from collections.abc import Callable
23
from typing import Any
34

@@ -12,21 +13,38 @@ class JSONDecodeError(ValueError):
1213
def __init__(self, msg: str, doc: str, pos: int) -> None: ...
1314

1415
class JSONDecoder:
16+
if sys.version_info >= (3, 15):
17+
array_hook: Callable[[list[Any]], Any] | None
1518
object_hook: Callable[[dict[str, Any]], Any]
1619
parse_float: Callable[[str], Any]
1720
parse_int: Callable[[str], Any]
1821
parse_constant: Callable[[str], Any]
1922
strict: bool
2023
object_pairs_hook: Callable[[list[tuple[str, Any]]], Any]
21-
def __init__(
22-
self,
23-
*,
24-
object_hook: Callable[[dict[str, Any]], Any] | None = None,
25-
parse_float: Callable[[str], Any] | None = None,
26-
parse_int: Callable[[str], Any] | None = None,
27-
parse_constant: Callable[[str], Any] | None = None,
28-
strict: bool = True,
29-
object_pairs_hook: Callable[[list[tuple[str, Any]]], Any] | None = None,
30-
) -> None: ...
24+
if sys.version_info >= (3, 15):
25+
def __init__(
26+
self,
27+
*,
28+
object_hook: Callable[[dict[str, Any]], Any] | None = None,
29+
parse_float: Callable[[str], Any] | None = None,
30+
parse_int: Callable[[str], Any] | None = None,
31+
parse_constant: Callable[[str], Any] | None = None,
32+
strict: bool = True,
33+
object_pairs_hook: Callable[[list[tuple[str, Any]]], Any] | None = None,
34+
array_hook: Callable[[list[Any]], Any] | None = None,
35+
) -> None: ...
36+
37+
else:
38+
def __init__(
39+
self,
40+
*,
41+
object_hook: Callable[[dict[str, Any]], Any] | None = None,
42+
parse_float: Callable[[str], Any] | None = None,
43+
parse_int: Callable[[str], Any] | None = None,
44+
parse_constant: Callable[[str], Any] | None = None,
45+
strict: bool = True,
46+
object_pairs_hook: Callable[[list[tuple[str, Any]]], Any] | None = None,
47+
) -> None: ...
48+
3149
def decode(self, s: str, _w: Callable[..., Any] = ...) -> Any: ... # _w is undocumented
3250
def raw_decode(self, s: str, idx: int = 0) -> tuple[Any, int]: ...

stdlib/sqlite3/__init__.pyi

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ from typing_extensions import Self, disjoint_base
6868
if sys.version_info < (3, 14):
6969
from sqlite3.dbapi2 import version_info as version_info
7070

71+
if sys.version_info >= (3, 15):
72+
from sqlite3.dbapi2 import SQLITE_KEYWORDS as SQLITE_KEYWORDS
73+
7174
if sys.version_info >= (3, 12):
7275
from sqlite3.dbapi2 import (
7376
LEGACY_TRANSACTION_CONTROL as LEGACY_TRANSACTION_CONTROL,
@@ -331,7 +334,10 @@ class Connection:
331334
def blobopen(self, table: str, column: str, row: int, /, *, readonly: bool = False, name: str = "main") -> Blob: ...
332335

333336
def commit(self) -> None: ...
334-
def create_aggregate(self, name: str, n_arg: int, aggregate_class: Callable[[], _AggregateProtocol]) -> None: ...
337+
if sys.version_info >= (3, 15):
338+
def create_aggregate(self, name: str, n_arg: int, aggregate_class: Callable[[], _AggregateProtocol], /) -> None: ...
339+
else:
340+
def create_aggregate(self, name: str, n_arg: int, aggregate_class: Callable[[], _AggregateProtocol]) -> None: ...
335341
if sys.version_info >= (3, 11):
336342
# num_params determines how many params will be passed to the aggregate class. We provide an overload
337343
# for the case where num_params = 1, which is expected to be the common case.
@@ -350,9 +356,15 @@ class Connection:
350356
) -> None: ...
351357

352358
def create_collation(self, name: str, callback: Callable[[str, str], SupportsIndex] | None, /) -> None: ...
353-
def create_function(
354-
self, name: str, narg: int, func: Callable[..., _SqliteData] | None, *, deterministic: bool = False
355-
) -> None: ...
359+
if sys.version_info >= (3, 15):
360+
def create_function(
361+
self, name: str, narg: int, func: Callable[..., _SqliteData] | None, /, *, deterministic: bool = False
362+
) -> None: ...
363+
else:
364+
def create_function(
365+
self, name: str, narg: int, func: Callable[..., _SqliteData] | None, *, deterministic: bool = False
366+
) -> None: ...
367+
356368
@overload
357369
def cursor(self, factory: None = None) -> Cursor: ...
358370
@overload
@@ -367,11 +379,18 @@ class Connection:
367379
def iterdump(self) -> Generator[str]: ...
368380

369381
def rollback(self) -> None: ...
370-
def set_authorizer(
371-
self, authorizer_callback: Callable[[int, str | None, str | None, str | None, str | None], int] | None
372-
) -> None: ...
373-
def set_progress_handler(self, progress_handler: Callable[[], int | None] | None, n: int) -> None: ...
374-
def set_trace_callback(self, trace_callback: Callable[[str], object] | None) -> None: ...
382+
if sys.version_info >= (3, 15):
383+
def set_authorizer(
384+
self, authorizer_callback: Callable[[int, str | None, str | None, str | None, str | None], int] | None, /
385+
) -> None: ...
386+
def set_progress_handler(self, progress_handler: Callable[[], int | None] | None, /, n: int) -> None: ...
387+
def set_trace_callback(self, trace_callback: Callable[[str], object] | None, /) -> None: ...
388+
else:
389+
def set_authorizer(
390+
self, authorizer_callback: Callable[[int, str | None, str | None, str | None, str | None], int] | None
391+
) -> None: ...
392+
def set_progress_handler(self, progress_handler: Callable[[], int | None] | None, n: int) -> None: ...
393+
def set_trace_callback(self, trace_callback: Callable[[str], object] | None) -> None: ...
375394
# enable_load_extension and load_extension is not available on python distributions compiled
376395
# without sqlite3 loadable extension support. see footnotes https://docs.python.org/3/library/sqlite3.html#f1
377396
def enable_load_extension(self, enable: bool, /) -> None: ...

stdlib/sqlite3/dbapi2.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ if sys.version_info >= (3, 12):
9090
SQLITE_DBCONFIG_WRITABLE_SCHEMA as SQLITE_DBCONFIG_WRITABLE_SCHEMA,
9191
)
9292

93+
if sys.version_info >= (3, 15):
94+
from _sqlite3 import SQLITE_KEYWORDS as SQLITE_KEYWORDS
95+
9396
if sys.version_info >= (3, 11):
9497
from _sqlite3 import (
9598
SQLITE_ABORT as SQLITE_ABORT,

0 commit comments

Comments
 (0)