Skip to content

Commit

Permalink
Fix:Slice.find apply on list only.
Browse files Browse the repository at this point in the history
  • Loading branch information
linw1995 committed Sep 24, 2020
1 parent 901354f commit c0e82d6
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions jsonpath/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,22 +609,21 @@ def _ensure_int_or_none(
else:
return value

def find(self, element: List[Any]) -> Any:
if isinstance(element, list):
start = self._ensure_int_or_none(self.start)
end = self._ensure_int_or_none(self.end)
step = self._ensure_int_or_none(self.step)
def find(self, element: List[Any]) -> List[Any]:
assert isinstance(element, list), "Slice.find apply on list only."

if start is None:
start = 0
if end is None:
end = len(element)
if step is None:
step = 1
start = self._ensure_int_or_none(self.start)
end = self._ensure_int_or_none(self.end)
step = self._ensure_int_or_none(self.step)

return element[start:end:step]
if start is None:
start = 0
if end is None:
end = len(element)
if step is None:
step = 1

raise JSONPathFindError
return element[start:end:step]


class Brace(Expr):
Expand Down

0 comments on commit c0e82d6

Please sign in to comment.