[responses] cast set to list.

This commit is contained in:
Joël Maïzi 2021-01-23 08:49:07 +01:00
parent d21ee175e9
commit a5300962ad
1 changed files with 9 additions and 4 deletions

View File

@ -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)
raise TypeError(f'Type {type(x)} is not handled in ORJSONResponse')
class HJSONResponse(ORJSONResponse):