Skip to content

Commit 7ef9522

Browse files
authored
[simplejson] Update to 4.1.* (#16046)
1 parent f979d3b commit 7ef9522

5 files changed

Lines changed: 18 additions & 4 deletions

File tree

stubs/simplejson/@tests/stubtest_allowlist.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
simplejson.scanner.make_scanner
33
simplejson.scanner.JSONDecodeError.__init__
44
simplejson.encoder.c_make_encoder
5+
simplejson.encoder.c_encode_basestring
6+
simplejson.encoder.py_encode_basestring
57
simplejson.encoder.c_encode_basestring_ascii
68
simplejson.encoder.py_encode_basestring_ascii
79

stubs/simplejson/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = "3.20.*"
1+
version = "4.1.*"
22
upstream-repository = "https://github.com/simplejson/simplejson"

stubs/simplejson/simplejson/__init__.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def loads(
124124
object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
125125
use_decimal: bool = False,
126126
allow_nan: bool = False,
127+
array_hook: Callable[[list[Any]], Any] | None = None, # transforms a JSON value to an arbitrary value
127128
**kw: Any,
128129
) -> Any: ...
129130
@overload
@@ -138,6 +139,7 @@ def loads(
138139
object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
139140
use_decimal: bool = False,
140141
allow_nan: bool = False,
142+
array_hook: Callable[[list[Any]], Any] | None = None, # transforms a JSON value to an arbitrary value
141143
) -> Any: ...
142144

143145
@overload
@@ -153,6 +155,7 @@ def load(
153155
object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
154156
use_decimal: bool = False,
155157
allow_nan: bool = False,
158+
array_hook: Callable[[list[Any]], Any] | None = None, # transforms a JSON value to an arbitrary value
156159
**kw: Any,
157160
) -> Any: ...
158161
@overload
@@ -167,6 +170,7 @@ def load(
167170
object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
168171
use_decimal: bool = False,
169172
allow_nan: bool = False,
173+
array_hook: Callable[[list[Any]], Any] | None = None, # transforms a JSON value to an arbitrary value
170174
) -> Any: ...
171175

172176
def simple_first(kv: tuple[_T, object]) -> tuple[bool, _T]: ...

stubs/simplejson/simplejson/decoder.pyi

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1+
from _typeshed import Incomplete
12
from collections.abc import Callable
23
from re import Match
34
from typing import Any, Literal
45

56
class JSONDecoder:
67
encoding: str
78
object_hook: Callable[[dict[Any, Any]], Any] | None
9+
# transforms a list of (key, json_value) pairs to an arbitrary value
10+
object_pairs_hook: Callable[[list[tuple[str, Any]]], Any] | None
811
parse_float: Callable[[str], Any] | None
912
parse_int: Callable[[str], Any] | None
1013
parse_constant: Callable[[str], Any] | None
1114
strict: bool
12-
object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None
15+
array_hook: Callable[[list[Any]], Any] | None # transforms a JSON value to an arbitrary value
16+
# They have many parameters, it might be better to use Protocol:
17+
parse_object: Callable[..., tuple[Incomplete, int]]
18+
parse_array: Callable[..., tuple[Incomplete, int]]
19+
parse_string: Callable[..., tuple[Incomplete, int]]
1320
memo: dict[Any, Any]
1421
scan_once: Callable[[str, int], tuple[bool, int]]
1522

@@ -23,6 +30,7 @@ class JSONDecoder:
2330
strict: bool = True,
2431
object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
2532
allow_nan: bool = False,
33+
array_hook: Callable[[list[Any]], Any] | None = None, # transforms a JSON value to an arbitrary value
2634
) -> None: ...
2735
def decode(self, s: str, _w: Callable[[str, int], Match[str]] = ..., _PY3: Literal[True] = True) -> Any: ...
2836
def raw_decode(

stubs/simplejson/simplejson/encoder.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import re
22
from _typeshed import SupportsRichComparison
33
from collections.abc import Callable, Iterator
4-
from typing import Any, Literal, NoReturn
4+
from typing import Any, NoReturn
55

66
ESCAPE: re.Pattern[str]
77
ESCAPE_ASCII: re.Pattern[str]
@@ -56,5 +56,5 @@ class JSONEncoder:
5656

5757
class JSONEncoderForHTML(JSONEncoder): ...
5858

59-
def encode_basestring(s: str | bytes, _PY3: Literal[True] = True, _q: str = '"') -> str: ...
59+
def encode_basestring(s: str | bytes, /) -> str: ...
6060
def encode_basestring_ascii(s: str | bytes, /) -> str: ...

0 commit comments

Comments
 (0)