json: require a JSONDecoder/JSONEncoder in cls (#3138)

This commit is contained in:
Ville Skyttä
2019-07-23 23:59:57 +03:00
committed by Sebastian Rittau
parent 67d091db15
commit 8e0d288ea4
2 changed files with 10 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
from typing import Any, IO, Optional, Tuple, Callable, Dict, List, Union, Text, Protocol
from typing import Any, IO, Optional, Tuple, Callable, Dict, List, Union, Text, Protocol, Type
class JSONDecodeError(ValueError):
def dumps(self, obj: Any) -> str: ...
@@ -11,7 +11,7 @@ def dumps(obj: Any,
ensure_ascii: bool = ...,
check_circular: bool = ...,
allow_nan: bool = ...,
cls: Any = ...,
cls: Optional[Type[JSONEncoder]] = ...,
indent: Optional[int] = ...,
separators: Optional[Tuple[str, str]] = ...,
encoding: str = ...,
@@ -25,7 +25,7 @@ def dump(obj: Any,
ensure_ascii: bool = ...,
check_circular: bool = ...,
allow_nan: bool = ...,
cls: Any = ...,
cls: Optional[Type[JSONEncoder]] = ...,
indent: Optional[int] = ...,
separators: Optional[Tuple[str, str]] = ...,
encoding: str = ...,
@@ -35,7 +35,7 @@ def dump(obj: Any,
def loads(s: Union[Text, bytes],
encoding: Any = ...,
cls: Any = ...,
cls: Optional[Type[JSONDecoder]] = ...,
object_hook: Optional[Callable[[Dict], Any]] = ...,
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,
@@ -48,7 +48,7 @@ class _Reader(Protocol):
def load(fp: _Reader,
encoding: Optional[str] = ...,
cls: Any = ...,
cls: Optional[Type[JSONDecoder]] = ...,
object_hook: Optional[Callable[[Dict], Any]] = ...,
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,