From a5300962ad179298910a6efcab70837149329fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Ma=C3=AFzi?= Date: Sat, 23 Jan 2021 08:49:07 +0100 Subject: [PATCH] [responses] cast set to list. --- halfapi/lib/responses.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/halfapi/lib/responses.py b/halfapi/lib/responses.py index 4ab33f8..0ed2f1f 100644 --- a/halfapi/lib/responses.py +++ b/halfapi/lib/responses.py @@ -58,14 +58,19 @@ class ORJSONResponse(JSONResponse): @staticmethod def default_cast(x): - types = { + str_types = { decimal.Decimal } + list_types = { + type(set) + } - if type(x) not in types: - raise TypeError('Type is not handled in ORJSONResponse') + if type(x) in str_types: + return str(x) + if type(x) in list_types: + return list(x) - return str(x) + raise TypeError(f'Type {type(x)} is not handled in ORJSONResponse') class HJSONResponse(ORJSONResponse):