From babefe7eb27e451b48b0f1d4b08633b2a6daa8ef Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Jul 2026 10:48:40 +0000 Subject: [PATCH 1/4] Initial plan From 420df7e938c524e384a449396fcf5a08681dd2af Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Jul 2026 10:51:21 +0000 Subject: [PATCH 2/4] fix keypaths separator validation and test coverage --- benedict/core/keypaths.py | 5 +++-- tests/core/test_keypaths.py | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/benedict/core/keypaths.py b/benedict/core/keypaths.py index ca4c9dea..5a0a2295 100644 --- a/benedict/core/keypaths.py +++ b/benedict/core/keypaths.py @@ -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 separator == "": 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] diff --git a/tests/core/test_keypaths.py b/tests/core/test_keypaths.py index 5d4faa6f..ceb7afc7 100644 --- a/tests/core/test_keypaths.py +++ b/tests/core/test_keypaths.py @@ -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": { @@ -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", From 0a3d3909a98a4eea0190e3e6032fcd693eaef923 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Jul 2026 10:52:19 +0000 Subject: [PATCH 3/4] refine keypaths separator validation --- benedict/core/keypaths.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benedict/core/keypaths.py b/benedict/core/keypaths.py index 5a0a2295..ce9a25c1 100644 --- a/benedict/core/keypaths.py +++ b/benedict/core/keypaths.py @@ -15,7 +15,7 @@ def keypaths( ) -> list[str]: if separator is None: separator = "." - if not type_util.is_string(separator) or separator == "": + if not type_util.is_string(separator) or not separator: 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] From c248664df06b9b3f0b4061415a06607a7917ec7b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Jul 2026 10:53:05 +0000 Subject: [PATCH 4/4] finalize keypaths separator check --- benedict/core/keypaths.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benedict/core/keypaths.py b/benedict/core/keypaths.py index ce9a25c1..6634cab8 100644 --- a/benedict/core/keypaths.py +++ b/benedict/core/keypaths.py @@ -15,7 +15,7 @@ def keypaths( ) -> list[str]: if separator is None: separator = "." - if not type_util.is_string(separator) or not 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]