Skip to content

to_dict() fails to convert Addicts inside lists in lists #155

Open
@ericjmcd

Description

@ericjmcd

I haven't tried to find all the corner cases, but a dictionary that has a list of lists with a value that is a dict, will correctly convert the inner dict into an Addict. However, when converting back to a pure dict with to_dict() the inner Addict is not converted.

addict version 2.4 in Python 3.12

from addict import Dict
orig = {'list': [[{'d': 1}]]}
conv = Dict(orig)
assert(isinstance(conv.list[0][0], Dict))  # Passes - inner dict becomes a Dict
final = conv.to_dict()
inner_dict = final['list'][0][0]
assert(not isinstance(inner_dict, Dict))  # Fails - inner dict is still a Dict

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions