From 6d6d456a012deb897f858256db46662c8c712f98 Mon Sep 17 00:00:00 2001 From: donbarbos Date: Mon, 20 Jul 2026 17:01:58 +0400 Subject: [PATCH 1/2] [simplejson] Update to 4.1.* Closes: #15648 --- stubs/simplejson/@tests/stubtest_allowlist.txt | 2 ++ stubs/simplejson/METADATA.toml | 2 +- stubs/simplejson/simplejson/__init__.pyi | 4 ++++ stubs/simplejson/simplejson/decoder.pyi | 9 ++++++++- stubs/simplejson/simplejson/encoder.pyi | 4 ++-- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/stubs/simplejson/@tests/stubtest_allowlist.txt b/stubs/simplejson/@tests/stubtest_allowlist.txt index 84e705994309..ebb5d87976c4 100644 --- a/stubs/simplejson/@tests/stubtest_allowlist.txt +++ b/stubs/simplejson/@tests/stubtest_allowlist.txt @@ -2,6 +2,8 @@ simplejson.scanner.make_scanner simplejson.scanner.JSONDecodeError.__init__ simplejson.encoder.c_make_encoder +simplejson.encoder.c_encode_basestring +simplejson.encoder.py_encode_basestring simplejson.encoder.c_encode_basestring_ascii simplejson.encoder.py_encode_basestring_ascii diff --git a/stubs/simplejson/METADATA.toml b/stubs/simplejson/METADATA.toml index 63c9ff16b4b7..d88621057572 100644 --- a/stubs/simplejson/METADATA.toml +++ b/stubs/simplejson/METADATA.toml @@ -1,2 +1,2 @@ -version = "3.20.*" +version = "4.1.*" upstream-repository = "https://github.com/simplejson/simplejson" diff --git a/stubs/simplejson/simplejson/__init__.pyi b/stubs/simplejson/simplejson/__init__.pyi index 73dd284fbe41..fbe776678f1c 100644 --- a/stubs/simplejson/simplejson/__init__.pyi +++ b/stubs/simplejson/simplejson/__init__.pyi @@ -124,6 +124,7 @@ def loads( object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None, use_decimal: bool = False, allow_nan: bool = False, + array_hook: Callable[[list[Any]], Any] | None = None, **kw: Any, ) -> Any: ... @overload @@ -138,6 +139,7 @@ def loads( object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None, use_decimal: bool = False, allow_nan: bool = False, + array_hook: Callable[[list[Any]], Any] | None = None, ) -> Any: ... @overload @@ -153,6 +155,7 @@ def load( object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None, use_decimal: bool = False, allow_nan: bool = False, + array_hook: Callable[[list[Any]], Any] | None = None, **kw: Any, ) -> Any: ... @overload @@ -167,6 +170,7 @@ def load( object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None, use_decimal: bool = False, allow_nan: bool = False, + array_hook: Callable[[list[Any]], Any] | None = None, ) -> Any: ... def simple_first(kv: tuple[_T, object]) -> tuple[bool, _T]: ... diff --git a/stubs/simplejson/simplejson/decoder.pyi b/stubs/simplejson/simplejson/decoder.pyi index 4afa6ea9360c..0aa17e000676 100644 --- a/stubs/simplejson/simplejson/decoder.pyi +++ b/stubs/simplejson/simplejson/decoder.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Callable from re import Match from typing import Any, Literal @@ -5,11 +6,16 @@ from typing import Any, Literal class JSONDecoder: encoding: str object_hook: Callable[[dict[Any, Any]], Any] | None + object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None parse_float: Callable[[str], Any] | None parse_int: Callable[[str], Any] | None parse_constant: Callable[[str], Any] | None strict: bool - object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None + array_hook: Callable[[list[Any]], Any] | None + # They have many parameters, it might be better to use Protocol: + parse_object: Callable[..., tuple[Incomplete, int]] + parse_array: Callable[..., tuple[Incomplete, int]] + parse_string: Callable[..., tuple[Incomplete, int]] memo: dict[Any, Any] scan_once: Callable[[str, int], tuple[bool, int]] @@ -23,6 +29,7 @@ class JSONDecoder: strict: bool = True, object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None, allow_nan: bool = False, + array_hook: Callable[[list[Any]], Any] | None = None, ) -> None: ... def decode(self, s: str, _w: Callable[[str, int], Match[str]] = ..., _PY3: Literal[True] = True) -> Any: ... def raw_decode( diff --git a/stubs/simplejson/simplejson/encoder.pyi b/stubs/simplejson/simplejson/encoder.pyi index 15378765980d..eebf18a2503e 100644 --- a/stubs/simplejson/simplejson/encoder.pyi +++ b/stubs/simplejson/simplejson/encoder.pyi @@ -1,7 +1,7 @@ import re from _typeshed import SupportsRichComparison from collections.abc import Callable, Iterator -from typing import Any, Literal, NoReturn +from typing import Any, NoReturn ESCAPE: re.Pattern[str] ESCAPE_ASCII: re.Pattern[str] @@ -56,5 +56,5 @@ class JSONEncoder: class JSONEncoderForHTML(JSONEncoder): ... -def encode_basestring(s: str | bytes, _PY3: Literal[True] = True, _q: str = '"') -> str: ... +def encode_basestring(s: str | bytes, /) -> str: ... def encode_basestring_ascii(s: str | bytes, /) -> str: ... From 5d10369cf0cb5645a03cdb54a0f3c8eb4c3498c5 Mon Sep 17 00:00:00 2001 From: Semyon Moroz Date: Tue, 21 Jul 2026 11:43:27 +0000 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Sebastian Rittau --- stubs/simplejson/simplejson/__init__.pyi | 8 ++++---- stubs/simplejson/simplejson/decoder.pyi | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/stubs/simplejson/simplejson/__init__.pyi b/stubs/simplejson/simplejson/__init__.pyi index fbe776678f1c..b89f04f64fdf 100644 --- a/stubs/simplejson/simplejson/__init__.pyi +++ b/stubs/simplejson/simplejson/__init__.pyi @@ -124,7 +124,7 @@ def loads( object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None, use_decimal: bool = False, allow_nan: bool = False, - array_hook: Callable[[list[Any]], Any] | None = None, + array_hook: Callable[[list[Any]], Any] | None = None, # transforms a JSON value to an arbitrary value **kw: Any, ) -> Any: ... @overload @@ -139,7 +139,7 @@ def loads( object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None, use_decimal: bool = False, allow_nan: bool = False, - array_hook: Callable[[list[Any]], Any] | None = None, + array_hook: Callable[[list[Any]], Any] | None = None, # transforms a JSON value to an arbitrary value ) -> Any: ... @overload @@ -155,7 +155,7 @@ def load( object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None, use_decimal: bool = False, allow_nan: bool = False, - array_hook: Callable[[list[Any]], Any] | None = None, + array_hook: Callable[[list[Any]], Any] | None = None, # transforms a JSON value to an arbitrary value **kw: Any, ) -> Any: ... @overload @@ -170,7 +170,7 @@ def load( object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None, use_decimal: bool = False, allow_nan: bool = False, - array_hook: Callable[[list[Any]], Any] | None = None, + array_hook: Callable[[list[Any]], Any] | None = None, # transforms a JSON value to an arbitrary value ) -> Any: ... def simple_first(kv: tuple[_T, object]) -> tuple[bool, _T]: ... diff --git a/stubs/simplejson/simplejson/decoder.pyi b/stubs/simplejson/simplejson/decoder.pyi index 0aa17e000676..3fc18bc176e5 100644 --- a/stubs/simplejson/simplejson/decoder.pyi +++ b/stubs/simplejson/simplejson/decoder.pyi @@ -6,12 +6,13 @@ from typing import Any, Literal class JSONDecoder: encoding: str object_hook: Callable[[dict[Any, Any]], Any] | None - object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None + # transforms a list of (key, json_value) pairs to an arbitrary value + object_pairs_hook: Callable[[list[tuple[str, Any]]], Any] | None parse_float: Callable[[str], Any] | None parse_int: Callable[[str], Any] | None parse_constant: Callable[[str], Any] | None strict: bool - array_hook: Callable[[list[Any]], Any] | None + array_hook: Callable[[list[Any]], Any] | None # transforms a JSON value to an arbitrary value # They have many parameters, it might be better to use Protocol: parse_object: Callable[..., tuple[Incomplete, int]] parse_array: Callable[..., tuple[Incomplete, int]] @@ -29,7 +30,7 @@ class JSONDecoder: strict: bool = True, object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None, allow_nan: bool = False, - array_hook: Callable[[list[Any]], Any] | None = None, + array_hook: Callable[[list[Any]], Any] | None = None, # transforms a JSON value to an arbitrary value ) -> None: ... def decode(self, s: str, _w: Callable[[str, int], Match[str]] = ..., _PY3: Literal[True] = True) -> Any: ... def raw_decode(