diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2017-02-08 14:31:59 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2017-02-08 18:38:42 +0900 |
commit | 6fa0262802a09050e09445c9fd630c69b5ad1204 (patch) | |
tree | a2ad8f7849540d1b027e0b99d9913394b23c58d8 /sphinx/util/jsonimpl.py | |
parent | 81eb101e9f8fcee1c439ee0dd501d135eced01c6 (diff) | |
download | sphinx-git-6fa0262802a09050e09445c9fd630c69b5ad1204.tar.gz |
Fix mypy violations
Diffstat (limited to 'sphinx/util/jsonimpl.py')
-rw-r--r-- | sphinx/util/jsonimpl.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sphinx/util/jsonimpl.py b/sphinx/util/jsonimpl.py index 215dfe44d..e5f6a0e72 100644 --- a/sphinx/util/jsonimpl.py +++ b/sphinx/util/jsonimpl.py @@ -14,28 +14,37 @@ import json from six import text_type from six.moves import UserString +if False: + # For type annotation + from typing import Any, IO # NOQA + class SphinxJSONEncoder(json.JSONEncoder): """JSONEncoder subclass that forces translation proxies.""" def default(self, obj): + # type: (Any) -> unicode if isinstance(obj, UserString): return text_type(obj) return json.JSONEncoder.default(self, obj) def dump(obj, fp, *args, **kwds): + # type: (Any, IO, Any, Any) -> unicode kwds['cls'] = SphinxJSONEncoder - return json.dump(obj, fp, *args, **kwds) + json.dump(obj, fp, *args, **kwds) def dumps(obj, *args, **kwds): + # type: (Any, Any, Any) -> unicode kwds['cls'] = SphinxJSONEncoder return json.dumps(obj, *args, **kwds) def load(*args, **kwds): + # type: (Any, Any) -> Any return json.load(*args, **kwds) def loads(*args, **kwds): + # type: (Any, Any) -> Any return json.loads(*args, **kwds) |