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..b89f04f64fdf 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, # transforms a JSON value to an arbitrary value **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, # transforms a JSON value to an arbitrary value ) -> 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, # transforms a JSON value to an arbitrary value **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, # 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 4afa6ea9360c..3fc18bc176e5 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,17 @@ from typing import Any, Literal class JSONDecoder: encoding: str object_hook: Callable[[dict[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 - object_pairs_hook: Callable[[list[tuple[Any, 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]] + parse_string: Callable[..., tuple[Incomplete, int]] memo: dict[Any, Any] scan_once: Callable[[str, int], tuple[bool, int]] @@ -23,6 +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, # 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( 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: ...