diff --git a/stubs/simplejson/@tests/test_cases/check_simplejson.py b/stubs/simplejson/@tests/test_cases/check_simplejson.py index c62fd73dad6e..7b2a6717a96f 100644 --- a/stubs/simplejson/@tests/test_cases/check_simplejson.py +++ b/stubs/simplejson/@tests/test_cases/check_simplejson.py @@ -1,8 +1,9 @@ from __future__ import annotations +from typing import Any from typing_extensions import assert_type -from simplejson import JSONEncoder, dumps +from simplejson import JSONDecoder, JSONEncoder, dumps class CustomEncoder(JSONEncoder): # eventhough it does not have `extra_kw` arg. @@ -14,3 +15,14 @@ class CustomEncoder(JSONEncoder): # eventhough it does not have `extra_kw` arg. # Ok: assert_type(dumps([], cls=CustomEncoder, extra_kw=True), str) + +decoder = JSONDecoder() +assert_type(decoder.scan_once("{}", 0), tuple[Any, int]) +assert_type(decoder.parse_string('"hello"', 1), tuple[str, int]) +assert_type(decoder.parse_array(("[]", 1), decoder.scan_once), tuple[Any, int]) +assert_type( + decoder.parse_object( + ("{}", 1), decoder.encoding, decoder.strict, decoder.scan_once, decoder.object_hook, decoder.object_pairs_hook + ), + tuple[Any, int], +) diff --git a/stubs/simplejson/simplejson/decoder.pyi b/stubs/simplejson/simplejson/decoder.pyi index 3fc18bc176e5..b45e81919fd3 100644 --- a/stubs/simplejson/simplejson/decoder.pyi +++ b/stubs/simplejson/simplejson/decoder.pyi @@ -1,4 +1,3 @@ -from _typeshed import Incomplete from collections.abc import Callable from re import Match from typing import Any, Literal @@ -14,11 +13,11 @@ class JSONDecoder: strict: bool 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]] + parse_object: Callable[..., tuple[Any, int]] + parse_array: Callable[..., tuple[Any, int]] + parse_string: Callable[..., tuple[str, int]] memo: dict[Any, Any] - scan_once: Callable[[str, int], tuple[bool, int]] + scan_once: Callable[[str, int], tuple[Any, int]] def __init__( self,