Skip to content

Commit aa8833a

Browse files
committed
Add/fix __eq__()
1 parent cbf92ba commit aa8833a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

jsonpath_ng/ext/filter.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ def __repr__(self):
7171
def __str__(self):
7272
return '[?%s]' % self.expressions
7373

74+
def __eq__(self, other):
75+
return (isinstance(other, Filter)
76+
and self.expressions == other.expressions)
77+
7478

7579
class Expression(JSONPath):
7680
"""The JSONQuery expression"""
@@ -108,7 +112,7 @@ def find(self, datum):
108112
return found
109113

110114
def __eq__(self, other):
111-
return (isinstance(other, Filter) and
115+
return (isinstance(other, Expression) and
112116
self.target == other.target and
113117
self.op == other.op and
114118
self.value == other.value)

jsonpath_ng/jsonpath.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,10 @@ def __str__(self):
439439
def __eq__(self, other):
440440
return isinstance(other, Descendants) and self.left == other.left and self.right == other.right
441441

442+
def __repr__(self):
443+
return '%s(%r, %r)' % (self.__class__.__name__, self.left, self.right)
444+
445+
442446
class Union(JSONPath):
443447
"""
444448
JSONPath that returns the union of the results of each match.

0 commit comments

Comments
 (0)