[python-flask] Apply template tweaks to improve lint results (#6826)

The linting results for the generated samples are as follows
where the first number is the BEFORE and the second is AFTER.

flaskConnexion          1843 vs. 20
flaskConnexion-python2  1841 vs. 19

For the complete details please see the following gist.
https://gist.github.com/kenjones-cisco/edc9d71ef7fd2bf23714ecbb693d52b3
This commit is contained in:
Kenny Jones
2017-10-27 10:18:14 -04:00
committed by wing328
parent f472b623f0
commit 28d14e34c4
46 changed files with 1276 additions and 1239 deletions

View File

@@ -1,6 +1,8 @@
from six import iteritems
from swagger_server.models.base_model_ import Model
from connexion.apps.flask_app import FlaskJSONEncoder
import six
from swagger_server.models.base_model_ import Model
class JSONEncoder(FlaskJSONEncoder):
include_nulls = False
@@ -8,11 +10,11 @@ class JSONEncoder(FlaskJSONEncoder):
def default(self, o):
if isinstance(o, Model):
dikt = {}
for attr, _ in iteritems(o.swagger_types):
for attr, _ in six.iteritems(o.swagger_types):
value = getattr(o, attr)
if value is None and not self.include_nulls:
continue
attr = o.attribute_map[attr]
dikt[attr] = value
return dikt
return FlaskJSONEncoder.default(self, o)
return FlaskJSONEncoder.default(self, o)