# Note that we check for `Sequence` and not `list` because we want to support any kind of sequence, like `list`, `tuple`, `set`, etc.
# Also, we check that it's not a `bytes` object, because `bytes` is also a `Sequence`, but we want to rely on the TYPE_ENCODERS for `bytes` and avoid code duplication.
# Check if it's a named tuple, and if so, encode it as a dict (instead of a list) if `named_tuple_as_dict` is `True`.
if(
named_tuple_as_dict
andgetattr(obj,"_asdict",None)isnotNone
andcallable(obj._asdict)
):
returnjsonable_encoder(
obj._asdict(),
include=include,
exclude=exclude,
by_alias=by_alias,
@ -345,16 +345,15 @@ def jsonable_encoder(
custom_encoder=custom_encoder,
sqlalchemy_safe=sqlalchemy_safe,
)
)
returnencoded_list
if(
named_tuple_as_dict
andgetattr(obj,"_asdict",None)isnotNone
andcallable(obj._asdict)
):
returnjsonable_encoder(
obj._asdict(),
# Note that we check for `Sequence` and not `list` because we want to support any kind of sequence, like `list`, `tuple`, `set`, etc.
# Also, we check that it's not a `bytes` object, because `bytes` is also a `Sequence`, but we want to rely on the TYPE_ENCODERS for `bytes` and avoid code duplication.