From f6a0b8de0c0c27ed613653f7c31085ead4ffb8f8 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 27 Jan 2016 14:41:53 -0800 Subject: [PATCH] Expand stub for simplejson module to include decoders/encoders. --- stdlib/2.7/simplejson/__init__.pyi | 10 ++++++++++ stdlib/2.7/simplejson/decoder.pyi | 6 ++++++ stdlib/2.7/simplejson/encoder.pyi | 9 +++++++++ stdlib/2.7/{simplejson.pyi => simplejson/scanner.pyi} | 5 ----- 4 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 stdlib/2.7/simplejson/__init__.pyi create mode 100644 stdlib/2.7/simplejson/decoder.pyi create mode 100644 stdlib/2.7/simplejson/encoder.pyi rename stdlib/2.7/{simplejson.pyi => simplejson/scanner.pyi} (59%) diff --git a/stdlib/2.7/simplejson/__init__.pyi b/stdlib/2.7/simplejson/__init__.pyi new file mode 100644 index 000000000..84e648333 --- /dev/null +++ b/stdlib/2.7/simplejson/__init__.pyi @@ -0,0 +1,10 @@ +from typing import Any, IO + +def dumps(obj: Any) -> str: ... +def dump(obj: Any, fp: IO[str], *args: Any, **kwds: Any) -> None: ... +def loads(s: str, **kwds: Any) -> Any: ... +def load(fp: IO[str]) -> Any: ... + +from .scanner import JSONDecodeError +from .decoder import JSONDecoder +from .encoder import JSONEncoder, JSONEncoderForHTML diff --git a/stdlib/2.7/simplejson/decoder.pyi b/stdlib/2.7/simplejson/decoder.pyi new file mode 100644 index 000000000..59111ce66 --- /dev/null +++ b/stdlib/2.7/simplejson/decoder.pyi @@ -0,0 +1,6 @@ +from typing import Any, Match + +class JSONDecoder(object): + def __init__(self, **kwargs): ... + def decode(self, s: str, _w: Match[str], _PY3: bool): ... + def raw_decode(self, s: str, idx: int, _w: Match[str], _PY3: bool): ... diff --git a/stdlib/2.7/simplejson/encoder.pyi b/stdlib/2.7/simplejson/encoder.pyi new file mode 100644 index 000000000..0e3180661 --- /dev/null +++ b/stdlib/2.7/simplejson/encoder.pyi @@ -0,0 +1,9 @@ +from typing import Any, IO + +class JSONEncoder(object): + def __init__(self, *args, **kwargs): ... + def encode(self, o: Any): ... + def default(self, o: Any): ... + def iterencode(self, o: Any, _one_shot: bool): ... + +class JSONEncoderForHTML(JSONEncoder): ... diff --git a/stdlib/2.7/simplejson.pyi b/stdlib/2.7/simplejson/scanner.pyi similarity index 59% rename from stdlib/2.7/simplejson.pyi rename to stdlib/2.7/simplejson/scanner.pyi index aa3a18a48..760b24dc0 100644 --- a/stdlib/2.7/simplejson.pyi +++ b/stdlib/2.7/simplejson/scanner.pyi @@ -5,8 +5,3 @@ class JSONDecodeError(ValueError): def dump(self, obj: Any, fp: IO[str], *args: Any, **kwds: Any) -> None: ... def loads(self, s: str) -> Any: ... def load(self, fp: IO[str]) -> Any: ... - -def dumps(obj: Any) -> str: ... -def dump(obj: Any, fp: IO[str], *args: Any, **kwds: Any) -> None: ... -def loads(s: str, **kwds: Any) -> Any: ... -def load(fp: IO[str]) -> Any: ...