Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions benedict/core/keypaths.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ def keypaths(
indexes: bool = False,
sort: bool = True,
) -> list[str]:
separator = separator or "."
if not type_util.is_string(separator):
if separator is None:
separator = "."
if not type_util.is_string(separator) or len(separator) == 0:
raise ValueError("separator argument must be a (non-empty) string.")
kls = keylists(d, indexes=indexes)
kps = [separator.join([f"{key}" for key in kl]) for kl in kls]
Expand Down
6 changes: 2 additions & 4 deletions tests/core/test_keypaths.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_keypaths_with_invalid_separator(self) -> None:
with self.assertRaises(ValueError):
_ = _keypaths(i, separator=True) # type: ignore[arg-type]

def test_keypaths_without_separator(self) -> None:
def test_keypaths_with_none_separator(self) -> None:
i = {
"a": 1,
"b": {
Expand All @@ -120,9 +120,7 @@ def test_keypaths_without_separator(self) -> None:
},
},
}
# with self.assertRaises(ValueError):
# o = _keypaths(i, separator=None)
o = _keypaths(i)
o = _keypaths(i, separator=None)
r = [
"a",
"b",
Expand Down
Loading