Skip to content

Commit 748f74d

Browse files
Support lists of non-dicts in normalize_dict()
1 parent 5c3aaf5 commit 748f74d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

ecs_logging/_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ def flatten_dict(value):
6464
def normalize_dict(value):
6565
# type: (Dict[str, Any]) -> Dict[str, Any]
6666
"""Expands all dotted names to nested dictionaries"""
67+
if not isinstance(value, dict):
68+
return value
6769
keys = list(value.keys())
6870
for key in keys:
6971
if "." in key:

tests/test_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ def test_normalize_dict():
2626
assert normalize_dict(
2727
{"a": {"b": 1}, "a.c": {"d.e": {"f": 1}, "d.e.g": [{"f.c": 2}]}}
2828
) == {"a": {"b": 1, "c": {"d": {"e": {"f": 1, "g": [{"f": {"c": 2}}]}}}}}
29+
30+
31+
def test_normalize_dict_with_array():
32+
assert normalize_dict({"a": ["1", "2"]}) == {"a": ["1", "2"]}

0 commit comments

Comments
 (0)