From 003fc6fa312f31c6c2eabd875ff4b42a8589ea4e Mon Sep 17 00:00:00 2001 From: Shantanu Date: Fri, 21 Feb 2020 21:21:32 -0800 Subject: [PATCH] json: mark keyword-only args, remove deprecated arg (#3756) * json: mark keyword-only args Technically only true for Python 3.6+, but I didn't feel like copying over the whole file just for Python 3.5. Let me know and I can. * json: remove encoding from loads This has been ignored and deprecated since 3.1 and will be removed in 3.9 It no longer even shows up in inspect.signature (in 3.8 it emits the deprecation warning based on kwargs) * json: update whitelists --- stdlib/3/json/__init__.pyi | 5 ++++- tests/stubtest_whitelists/py35.txt | 4 ++++ tests/stubtest_whitelists/py36.txt | 4 ---- tests/stubtest_whitelists/py37.txt | 4 ---- tests/stubtest_whitelists/py38.txt | 4 ---- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/stdlib/3/json/__init__.pyi b/stdlib/3/json/__init__.pyi index 2f6374e3b..fe8569734 100644 --- a/stdlib/3/json/__init__.pyi +++ b/stdlib/3/json/__init__.pyi @@ -6,6 +6,7 @@ from .encoder import JSONEncoder as JSONEncoder from .decoder import JSONDecodeError as JSONDecodeError def dumps(obj: Any, + *, skipkeys: bool = ..., ensure_ascii: bool = ..., check_circular: bool = ..., @@ -19,6 +20,7 @@ def dumps(obj: Any, def dump(obj: Any, fp: IO[str], + *, skipkeys: bool = ..., ensure_ascii: bool = ..., check_circular: bool = ..., @@ -35,7 +37,7 @@ if sys.version_info >= (3, 6): else: _LoadsString = str def loads(s: _LoadsString, - encoding: Any = ..., # ignored and deprecated + *, cls: Optional[Type[JSONDecoder]] = ..., object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ..., parse_float: Optional[Callable[[str], Any]] = ..., @@ -48,6 +50,7 @@ class _Reader(Protocol): def read(self) -> _LoadsString: ... def load(fp: _Reader, + *, cls: Optional[Type[JSONDecoder]] = ..., object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ..., parse_float: Optional[Callable[[str], Any]] = ..., diff --git a/tests/stubtest_whitelists/py35.txt b/tests/stubtest_whitelists/py35.txt index a0d6dbbcd..809324c11 100644 --- a/tests/stubtest_whitelists/py35.txt +++ b/tests/stubtest_whitelists/py35.txt @@ -36,6 +36,10 @@ io.BufferedRandom.read1 io.BufferedReader.read1 io.StringIO.readline ipaddress._BaseNetwork.__init__ +json.dump +json.dumps +json.load +json.loads macpath.basename macpath.commonpath macpath.commonprefix diff --git a/tests/stubtest_whitelists/py36.txt b/tests/stubtest_whitelists/py36.txt index c80f09a9e..20c4d09af 100644 --- a/tests/stubtest_whitelists/py36.txt +++ b/tests/stubtest_whitelists/py36.txt @@ -39,10 +39,6 @@ io.BufferedRandom.read1 io.BufferedReader.read1 io.StringIO.readline ipaddress._BaseNetwork.__init__ -json.dump -json.dumps -json.load -json.loads logging.handlers.MemoryHandler.__init__ macpath.basename macpath.commonpath diff --git a/tests/stubtest_whitelists/py37.txt b/tests/stubtest_whitelists/py37.txt index 8acba2f28..f8b5e6a46 100644 --- a/tests/stubtest_whitelists/py37.txt +++ b/tests/stubtest_whitelists/py37.txt @@ -55,10 +55,6 @@ http.client.HTTPSConnection.__init__ http.server.SimpleHTTPRequestHandler.__init__ importlib.metadata ipaddress._BaseNetwork.__init__ -json.dump -json.dumps -json.load -json.loads logging.handlers.MemoryHandler.__init__ macpath.basename macpath.commonpath diff --git a/tests/stubtest_whitelists/py38.txt b/tests/stubtest_whitelists/py38.txt index 29e4c7d98..22b370fdc 100644 --- a/tests/stubtest_whitelists/py38.txt +++ b/tests/stubtest_whitelists/py38.txt @@ -123,10 +123,6 @@ ipaddress.IPv6Interface.hostmask ipaddress._BaseNetwork.broadcast_address ipaddress._BaseNetwork.hostmask itertools.tee -json.dump -json.dumps -json.load -json.loads logging.handlers.MemoryHandler.__init__ lzma.LZMACompressor.compress lzma.is_check_supported