Add hacking checks to watcher

The hacking checks enforce during the pep8 run functional validations of
the code to ensure deeper filters and code consistency.  This change set
adds the hacking checks to the wathcer project.  These checks were
seeded from the neutron project, which had a good set of base defaults.

This change set also updates the watcher project to be compliant with
these new hacking checks.

Change-Id: I6f4566d384a7400bddf228aa127a53e6ecc82c2e
This commit is contained in:
Drew Thorstensen
2016-07-20 16:05:01 -07:00
parent 65d3a4d75e
commit 7d704dbeec
31 changed files with 398 additions and 75 deletions

View File

@@ -15,7 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
from oslo_serialization import jsonutils
from oslo_utils import strutils
import six
import wsme
@@ -118,7 +118,7 @@ class JsonType(wtypes.UserType):
@staticmethod
def validate(value):
try:
json.dumps(value)
jsonutils.dumps(value, default=None)
except TypeError:
raise exception.Invalid(_('%s is not JSON serializable') % value)
else:

View File

@@ -20,10 +20,10 @@ response with one formatted so the client can parse it.
Based on pecan.middleware.errordocument
"""
import json
from xml import etree as et
from oslo_log import log
from oslo_serialization import jsonutils
import six
import webob
@@ -84,7 +84,8 @@ class ParsableErrorMiddleware(object):
else:
if six.PY3:
app_iter = [i.decode('utf-8') for i in app_iter]
body = [json.dumps({'error_message': '\n'.join(app_iter)})]
body = [jsonutils.dumps(
{'error_message': '\n'.join(app_iter)})]
if six.PY3:
body = [item.encode('utf-8') for item in body]
state['headers'].append(('Content-Type', 'application/json'))