@@ -51,11 +51,7 @@ def findall(
5151 if isinstance (data , str ):
5252 data = json .loads (data )
5353 return [
54- match .obj
55- for match in self .finditer (
56- data ,
57- filter_context = filter_context ,
58- )
54+ match .obj for match in self .finditer (data , filter_context = filter_context )
5955 ]
6056
6157 def finditer (
@@ -162,7 +158,8 @@ def findall(
162158 _objs = path .findall (data , filter_context = filter_context )
163159 if op == self .union_token :
164160 objs .extend (_objs )
165- elif op == self .intersection_token :
161+ else :
162+ assert op == self .intersection_token , op
166163 objs = [obj for obj in objs if obj in _objs ]
167164
168165 return objs
@@ -180,9 +177,10 @@ def finditer(
180177 _matches = path .finditer (data , filter_context = filter_context )
181178 if op == self .union_token :
182179 matches = itertools .chain (matches , _matches )
183- elif op == self .intersection_token :
180+ else :
181+ assert op == self .intersection_token
184182 _objs = [match .obj for match in _matches ]
185- _matches = (match for match in matches if match .obj in _objs )
183+ matches = (match for match in matches if match .obj in _objs )
186184
187185 return matches
188186
@@ -198,7 +196,8 @@ async def findall_async(
198196 _objs = await path .findall_async (data , filter_context = filter_context )
199197 if op == self .union_token :
200198 objs .extend (_objs )
201- elif op == self .intersection_token :
199+ else :
200+ assert op == self .intersection_token
202201 objs = [obj for obj in objs if obj in _objs ]
203202
204203 return objs
@@ -216,9 +215,10 @@ async def finditer_async(
216215 _matches = await path .finditer_async (data , filter_context = filter_context )
217216 if op == self .union_token :
218217 matches = _achain (matches , _matches )
219- elif op == self .intersection_token :
218+ else :
219+ assert op == self .intersection_token
220220 _objs = [match .obj async for match in _matches ]
221- _matches = (match async for match in matches if match .obj in _objs )
221+ matches = (match async for match in matches if match .obj in _objs )
222222
223223 return matches
224224
0 commit comments