Skip to content

Commit

Permalink
Merge c661eaa into 842ac70
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwoerpel committed Mar 5, 2024
2 parents 842ac70 + c661eaa commit 2fbfd42
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 66 deletions.
8 changes: 7 additions & 1 deletion anystore/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
from banal import is_mapping


def _clean(val: Any) -> Any:
if val is False:
return False
return val or None


def clean_dict(data: Any) -> dict[str, Any]:
"""
strip out defaultdict and ensure str keys (for serialization)
Expand All @@ -16,7 +22,7 @@ def clean_dict(data: Any) -> dict[str, Any]:
return {}
return _clean_dict(
{
str(k): clean_dict(dict(v)) or None if is_mapping(v) else v or None
str(k): clean_dict(dict(v)) or None if is_mapping(v) else _clean(v)
for k, v in data.items()
}
)
Expand Down
Loading

0 comments on commit 2fbfd42

Please sign in to comment.