Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for t in types:
# If primitive type, continue
if t in [int, float, bool, str, list, dict]:
typeList.append(t.__name__)
# Format passed in should be [bool]. Internal types should be homogenous
# Output should be [bool]
elif type(t) is list:
if len(t) > 1:
raise utils.SyntaxError("Lists can only have one internal type.")
if t[0] in [int, float, bool, str, list, dict]:
typeList.append([t[0].__name__])
else:
raise utils.SyntaxError("Unknown type ", t[0])
# Same as above-- homogenous key:value pairs, OR just the dict itself
elif t is dict:
typelist.append({k: v.reflect() if isinstance(v, Model) else v for k, v in t})
elif issubclass(t, model.Model):
typeList.append(t.reflect())
else:
print 'Type ' + str(t) + ' is not natively serializible!'
return json.dumps(typeList)
if types is None:
return json.dumps([None])
else:
typeList = []
for t in types:
# If primitive type, continue
if t in [int, float, bool, str, list, dict]:
typeList.append(t.__name__)
# Format passed in should be [bool]. Internal types should be homogenous
# Output should be [bool]
elif type(t) is list:
if len(t) > 1:
raise utils.SyntaxError("Lists can only have one internal type.")
if t[0] in [int, float, bool, str, list, dict]:
typeList.append([t[0].__name__])
else:
raise utils.SyntaxError("Unknown type ", t[0])
# Same as above-- homogenous key:value pairs, OR just the dict itself
elif t is dict:
typelist.append({k: v.reflect() if isinstance(v, Model) else v for k, v in t})
elif issubclass(t, model.Model):
typeList.append(t.reflect())
else:
print 'Type ' + str(t) + ' is not natively serializible!'