|
@ -32,7 +32,6 @@ def jsonable_encoder( |
|
|
exclude_defaults: bool = False, |
|
|
exclude_defaults: bool = False, |
|
|
exclude_none: bool = False, |
|
|
exclude_none: bool = False, |
|
|
custom_encoder: dict = {}, |
|
|
custom_encoder: dict = {}, |
|
|
sqlalchemy_safe: bool = True, |
|
|
|
|
|
) -> Any: |
|
|
) -> Any: |
|
|
if include is not None and not isinstance(include, set): |
|
|
if include is not None and not isinstance(include, set): |
|
|
include = set(include) |
|
|
include = set(include) |
|
@ -57,7 +56,6 @@ def jsonable_encoder( |
|
|
exclude_none=exclude_none, |
|
|
exclude_none=exclude_none, |
|
|
exclude_defaults=exclude_defaults, |
|
|
exclude_defaults=exclude_defaults, |
|
|
custom_encoder=encoder, |
|
|
custom_encoder=encoder, |
|
|
sqlalchemy_safe=sqlalchemy_safe, |
|
|
|
|
|
) |
|
|
) |
|
|
if isinstance(obj, Enum): |
|
|
if isinstance(obj, Enum): |
|
|
return obj.value |
|
|
return obj.value |
|
@ -68,14 +66,8 @@ def jsonable_encoder( |
|
|
if isinstance(obj, dict): |
|
|
if isinstance(obj, dict): |
|
|
encoded_dict = {} |
|
|
encoded_dict = {} |
|
|
for key, value in obj.items(): |
|
|
for key, value in obj.items(): |
|
|
if ( |
|
|
if (value is not None or not exclude_none) and ( |
|
|
( |
|
|
(include and key in include) or not exclude or key not in exclude |
|
|
not sqlalchemy_safe |
|
|
|
|
|
or (not isinstance(key, str)) |
|
|
|
|
|
or (not key.startswith("_sa")) |
|
|
|
|
|
) |
|
|
|
|
|
and (value is not None or not exclude_none) |
|
|
|
|
|
and ((include and key in include) or not exclude or key not in exclude) |
|
|
|
|
|
): |
|
|
): |
|
|
encoded_key = jsonable_encoder( |
|
|
encoded_key = jsonable_encoder( |
|
|
key, |
|
|
key, |
|
@ -83,7 +75,6 @@ def jsonable_encoder( |
|
|
exclude_unset=exclude_unset, |
|
|
exclude_unset=exclude_unset, |
|
|
exclude_none=exclude_none, |
|
|
exclude_none=exclude_none, |
|
|
custom_encoder=custom_encoder, |
|
|
custom_encoder=custom_encoder, |
|
|
sqlalchemy_safe=sqlalchemy_safe, |
|
|
|
|
|
) |
|
|
) |
|
|
encoded_value = jsonable_encoder( |
|
|
encoded_value = jsonable_encoder( |
|
|
value, |
|
|
value, |
|
@ -91,7 +82,6 @@ def jsonable_encoder( |
|
|
exclude_unset=exclude_unset, |
|
|
exclude_unset=exclude_unset, |
|
|
exclude_none=exclude_none, |
|
|
exclude_none=exclude_none, |
|
|
custom_encoder=custom_encoder, |
|
|
custom_encoder=custom_encoder, |
|
|
sqlalchemy_safe=sqlalchemy_safe, |
|
|
|
|
|
) |
|
|
) |
|
|
encoded_dict[encoded_key] = encoded_value |
|
|
encoded_dict[encoded_key] = encoded_value |
|
|
return encoded_dict |
|
|
return encoded_dict |
|
@ -108,7 +98,6 @@ def jsonable_encoder( |
|
|
exclude_defaults=exclude_defaults, |
|
|
exclude_defaults=exclude_defaults, |
|
|
exclude_none=exclude_none, |
|
|
exclude_none=exclude_none, |
|
|
custom_encoder=custom_encoder, |
|
|
custom_encoder=custom_encoder, |
|
|
sqlalchemy_safe=sqlalchemy_safe, |
|
|
|
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return encoded_list |
|
|
return encoded_list |
|
@ -144,5 +133,4 @@ def jsonable_encoder( |
|
|
exclude_defaults=exclude_defaults, |
|
|
exclude_defaults=exclude_defaults, |
|
|
exclude_none=exclude_none, |
|
|
exclude_none=exclude_none, |
|
|
custom_encoder=custom_encoder, |
|
|
custom_encoder=custom_encoder, |
|
|
sqlalchemy_safe=sqlalchemy_safe, |
|
|
|
|
|
) |
|
|
) |
|
|