From 333167cead254d797e75544493bc9f3d29e3c4a6 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Mon, 18 Sep 2023 19:13:29 -0500 Subject: [PATCH] fix(backport): Use 'paths(scalars)' as 'leaf_paths' filter is deprecated (#101) * Backport PR https://github.com/yadage/packtivity/pull/99 * The 'leaf_paths' filter has been deprecated for 9 years and was removed in jqlang v1.7 (jq v1.6) so use the 'paths(scalars)' filter. - c.f. https://github.com/jqlang/jq/pull/2666 - c.f. https://github.com/jqlang/jq/pull/426 * Remove upper bound on jq version - Reverts https://github.com/yadage/packtivity/pull/97 --- packtivity/datamodels/purejson.py | 2 +- packtivity/typedleafs.py | 2 +- packtivity/utils.py | 2 +- setup.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packtivity/datamodels/purejson.py b/packtivity/datamodels/purejson.py index 931d88a..e669b8d 100644 --- a/packtivity/datamodels/purejson.py +++ b/packtivity/datamodels/purejson.py @@ -50,7 +50,7 @@ def leafs(self): else: ptrs = [ jsonpointer.JsonPointer.from_parts(parts) - for parts in self.jq("leaf_paths", multiple_output=True).typed() + for parts in self.jq("paths(scalars)", multiple_output=True).typed() ] for p in ptrs: yield p, p.get(self.typed()) diff --git a/packtivity/typedleafs.py b/packtivity/typedleafs.py index c869156..7d66075 100644 --- a/packtivity/typedleafs.py +++ b/packtivity/typedleafs.py @@ -215,7 +215,7 @@ def leafs(self): else: ptrs = [ jsonpointer.JsonPointer.from_parts(parts) - for parts in self.jq("leaf_paths", multiple_output=True).typed() + for parts in self.jq("paths(scalars)", multiple_output=True).typed() ] for p in ptrs: yield p, p.get(self.typed()) diff --git a/packtivity/utils.py b/packtivity/utils.py index 1774d15..e03e6d2 100644 --- a/packtivity/utils.py +++ b/packtivity/utils.py @@ -32,7 +32,7 @@ def leaf_iterator(jsonable): if not isinstance(jsonable, (list, dict)): yield jsonpointer.JsonPointer(""), jsonable else: - allleafs = jq.jq("leaf_paths").transform(jsonable, multiple_output=True) + allleafs = jq.jq("paths(scalars)").transform(jsonable, multiple_output=True) leafpointers = [jsonpointer.JsonPointer.from_parts(x) for x in allleafs] for x in leafpointers: yield x, x.get(jsonable) diff --git a/setup.py b/setup.py index 458fc9a..b72ace3 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ "glob2", "jsonpointer", "jsonpath-rw", - "jq", + "jq>=1.0.0", "yadage-schemas", "mock", "checksumdir",