json: mark kwonly args, improve decode (#3679)

* json: mark args as kwonly for py36 on
* json: add undocumented arg to JSONDecoder.decode
This commit is contained in:
Shantanu
2020-01-29 02:20:08 -08:00
committed by GitHub
parent 26fd2b7968
commit 46d9b38fa1
2 changed files with 49 additions and 12 deletions

View File

@@ -1,3 +1,4 @@
import sys
from typing import Any, Callable, Dict, List, Optional, Tuple
class JSONDecodeError(ValueError):
@@ -16,11 +17,26 @@ class JSONDecoder:
strict: bool
object_pairs_hook: Callable[[List[Tuple[str, Any]]], Any]
def __init__(self, object_hook: Optional[Callable[[Dict[str, Any]], Any]] = ...,
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,
parse_constant: Optional[Callable[[str], Any]] = ...,
strict: bool = ...,
object_pairs_hook: Optional[Callable[[List[Tuple[str, Any]]], Any]] = ...) -> None: ...
def decode(self, s: str) -> Any: ...
if sys.version_info >= (3, 6):
def __init__(
self,
*,
object_hook: Optional[Callable[[Dict[str, Any]], Any]] = ...,
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,
parse_constant: Optional[Callable[[str], Any]] = ...,
strict: bool = ...,
object_pairs_hook: Optional[Callable[[List[Tuple[str, Any]]], Any]] = ...
) -> None: ...
else:
def __init__(
self,
object_hook: Optional[Callable[[Dict[str, Any]], Any]] = ...,
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,
parse_constant: Optional[Callable[[str], Any]] = ...,
strict: bool = ...,
object_pairs_hook: Optional[Callable[[List[Tuple[str, Any]]], Any]] = ...,
) -> None: ...
def decode(self, s: str, _w: Callable[..., Any] = ...) -> Any: ... # _w is undocumented
def raw_decode(self, s: str, idx: int = ...) -> Tuple[Any, int]: ...

View File

@@ -1,3 +1,4 @@
import sys
from typing import Any, Callable, Iterator, Optional, Tuple
class JSONEncoder:
@@ -11,11 +12,31 @@ class JSONEncoder:
sort_keys: bool
indent: int
def __init__(self, skipkeys: bool = ..., ensure_ascii: bool = ...,
check_circular: bool = ..., allow_nan: bool = ..., sort_keys: bool = ...,
indent: Optional[int] = ..., separators: Optional[Tuple[str, str]] = ...,
default: Optional[Callable[..., Any]] = ...) -> None: ...
if sys.version_info >= (3, 6):
def __init__(
self,
*,
skipkeys: bool = ...,
ensure_ascii: bool = ...,
check_circular: bool = ...,
allow_nan: bool = ...,
sort_keys: bool = ...,
indent: Optional[int] = ...,
separators: Optional[Tuple[str, str]] = ...,
default: Optional[Callable[..., Any]] = ...
) -> None: ...
else:
def __init__(
self,
skipkeys: bool = ...,
ensure_ascii: bool = ...,
check_circular: bool = ...,
allow_nan: bool = ...,
sort_keys: bool = ...,
indent: Optional[int] = ...,
separators: Optional[Tuple[str, str]] = ...,
default: Optional[Callable[..., Any]] = ...,
) -> None: ...
def default(self, o: Any) -> Any: ...
def encode(self, o: Any) -> str: ...
def iterencode(self, o: Any, _one_shot: bool = ...) -> Iterator[str]: ...