Skip to content

Commit 77ad2db

Browse files
committed
fix: fix unnecessary-comprehension
1 parent 8e06820 commit 77ad2db

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

jsonpath/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Author : zhangxianbing1
33
Date : 2020-12-27 09:22:14
44
LastEditors : zhangxianbing1
5-
LastEditTime : 2021-01-04 14:10:00
5+
LastEditTime : 2021-01-04 14:34:35
66
Description : JSONPath
77
"""
88
__version__ = "0.0.3"
@@ -220,7 +220,7 @@ def _trace(self, obj, i: int, path):
220220

221221
# slice
222222
if isinstance(obj, list) and JSONPath.REP_SLICE_CONTENT.fullmatch(step):
223-
obj = [(idx, v) for idx, v in enumerate(obj)]
223+
obj = list(enumerate(obj))
224224
vals = eval(f"obj[{step}]")
225225
for idx, v in vals:
226226
self._trace(v, i + 1, f"{path}{JSONPath.SEP}{idx}")
@@ -243,12 +243,12 @@ def _trace(self, obj, i: int, path):
243243
# sort
244244
if step.startswith("/(") and step.endswith(")"):
245245
if isinstance(obj, list):
246-
obj = [(idx, v) for idx, v in enumerate(obj)]
246+
obj = list(enumerate(obj))
247247
self._sorter(obj, step[2:-1])
248248
for idx, v in obj:
249249
self._trace(v, i + 1, f"{path}{JSONPath.SEP}{idx}")
250250
elif isinstance(obj, dict):
251-
obj = [(k, v) for k, v in obj.items()]
251+
obj = list(obj.items())
252252
self._sorter(obj, step[2:-1])
253253
for k, v in obj:
254254
self._trace(v, i + 1, f"{path}{JSONPath.SEP}{k}")

0 commit comments

Comments
 (0)