gmr / flatdict

Python module for interacting with nested dicts as a single level dict with delimited keys.
https://flatdict.readthedocs.io
BSD 3-Clause "New" or "Revised" License
111 stars 32 forks source link

as_dict() not working with empty dict values #43

Open eevleevs opened 4 years ago

eevleevs commented 4 years ago

If you have a value that is an empty dict, it will be set as another FlatDict, that is not cast back by as_dict().

Actual:

>>> FlatDict({'a': {}}).as_dict()
{'a': <FlatDict id=140733286897024 {}>"}

Expected:

>>> FlatDict({'a': {}}).as_dict()
{'a': {}}
CrashLaker commented 2 years ago

same issue. it depends on the use case but as a workaround i'm doing this

image

tgh19 commented 10 months ago

I have a PR out that should fix this https://github.com/gmr/flatdict/pull/57

print(FlatDict({'a': {}, 'b': []}).as_dict())
{'a': {}, 'b': []}