From f3aa93cb194394d92bb03904186af2bb31e6f80c Mon Sep 17 00:00:00 2001 From: Mike Heald Date: Mon, 6 Oct 2014 14:17:59 +0100 Subject: [PATCH] Fix pep8, docs, requirements issues in jsonutils and tests Fixes pep8 issues in jsonutils and tests, fixes documentation build issues, brings the version of hacking in line with openstack/requirements. Change-Id: I207c5d632f6c879613496d61931dc4817d5b74d0 --- oslo/serialization/jsonutils.py | 20 +++++++++++--------- test-requirements.txt | 2 +- tests/test_jsonutils.py | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/oslo/serialization/jsonutils.py b/oslo/serialization/jsonutils.py index a14b827..7637d5a 100644 --- a/oslo/serialization/jsonutils.py +++ b/oslo/serialization/jsonutils.py @@ -88,7 +88,6 @@ def to_primitive(value, convert_instances=False, convert_datetime=True, track the depth of the object inspections and don't go too deep. Therefore, convert_instances=True is lossy ... be aware. - """ # handle obvious types first - order of basic types determined by running # full tests on nova project, resulting in the following counts: @@ -175,9 +174,10 @@ JSONDecoder = json.JSONDecoder def dumps(obj, default=to_primitive, **kwargs): """Serialize ``obj`` to a JSON formatted ``str``. + :param obj: object to be serialized :param default: function that returns a serializable version of an object - :param kwargs: extra named parameters, please see documentation + :param kwargs: extra named parameters, please see documentation \ of `json.dumps `_ :returns: json formatted string """ @@ -188,11 +188,12 @@ def dumps(obj, default=to_primitive, **kwargs): def dump(obj, fp, *args, **kwargs): """Serialize ``obj`` as a JSON formatted stream to ``fp`` + :param obj: object to be serialized :param fp: a ``.write()``-supporting file-like object - :param args: extra arguments, please see documentation + :param args: extra arguments, please see documentation \ of `json.dump `_ - :param kwargs: extra named parameters, please see documentation + :param kwargs: extra named parameters, please see documentation \ of `json.dump `_ """ if is_simplejson: @@ -202,9 +203,10 @@ def dump(obj, fp, *args, **kwargs): def loads(s, encoding='utf-8', **kwargs): """Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a JSON + :param s: string to deserialize :param encoding: encoding used to interpret the string - :param kwargs: extra named parameters, please see documentation + :param kwargs: extra named parameters, please see documentation \ of `json.loads `_ :returns: python object """ @@ -212,11 +214,11 @@ def loads(s, encoding='utf-8', **kwargs): def load(fp, encoding='utf-8', **kwargs): - """Deserialize ``fp`` (a ``.read()``-supporting file-like object containing - a JSON document) to a Python object. - :param fp: a ``.write()``-supporting file-like object + """Deserialize ``fp`` to a Python object. + + :param fp: a ``.read()`` -supporting file-like object :param encoding: encoding used to interpret the string - :param kwargs: extra named parameters, please see documentation + :param kwargs: extra named parameters, please see documentation \ of `json.loads `_ :returns: python object """ diff --git a/test-requirements.txt b/test-requirements.txt index 03cd2ca..dc6268d 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,7 +1,7 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking>=0.5.6,<0.8 +hacking>=0.9.2,<0.10 mock>=1.0 netaddr>=0.7.12 diff --git a/tests/test_jsonutils.py b/tests/test_jsonutils.py index 882e71b..a1e1408 100644 --- a/tests/test_jsonutils.py +++ b/tests/test_jsonutils.py @@ -19,12 +19,12 @@ import json import mock import netaddr -from oslo.i18n import fixture from oslotest import base as test_base import simplejson import six import six.moves.xmlrpc_client as xmlrpclib +from oslo.i18n import fixture from oslo.serialization import jsonutils