@@ -22,22 +22,17 @@ def patternProperties(validator, patternProperties, instance, schema):
22
22
for pattern , subschema in patternProperties .items ():
23
23
for k , v in instance .items ():
24
24
if re .search (pattern , k ):
25
- for error in validator .descend (
25
+ yield from validator .descend (
26
26
v , subschema , path = k , schema_path = pattern ,
27
- ):
28
- yield error
27
+ )
29
28
30
29
31
30
def propertyNames (validator , propertyNames , instance , schema ):
32
31
if not validator .is_type (instance , "object" ):
33
32
return
34
33
35
34
for property in instance :
36
- for error in validator .descend (
37
- instance = property ,
38
- schema = propertyNames ,
39
- ):
40
- yield error
35
+ yield from validator .descend (instance = property , schema = propertyNames )
41
36
42
37
43
38
def additionalProperties (validator , aP , instance , schema ):
@@ -48,8 +43,7 @@ def additionalProperties(validator, aP, instance, schema):
48
43
49
44
if validator .is_type (aP , "object" ):
50
45
for extra in extras :
51
- for error in validator .descend (instance [extra ], aP , path = extra ):
52
- yield error
46
+ yield from validator .descend (instance [extra ], aP , path = extra )
53
47
elif not aP and extras :
54
48
if "patternProperties" in schema :
55
49
if len (extras ) == 1 :
@@ -86,8 +80,7 @@ def items(validator, items, instance, schema):
86
80
)
87
81
88
82
for index , item in enumerate (non_prefixed_items ):
89
- for error in validator .descend (item , items , path = index ):
90
- yield error
83
+ yield from validator .descend (item , items , path = index )
91
84
92
85
93
86
def additionalItems (validator , aI , instance , schema ):
@@ -100,8 +93,7 @@ def additionalItems(validator, aI, instance, schema):
100
93
len_items = len (schema .get ("items" , []))
101
94
if validator .is_type (aI , "object" ):
102
95
for index , item in enumerate (instance [len_items :], start = len_items ):
103
- for error in validator .descend (item , aI , path = index ):
104
- yield error
96
+ yield from validator .descend (item , aI , path = index )
105
97
elif not aI and len (instance ) > len (schema .get ("items" , [])):
106
98
error = "Additional items are not allowed (%s %s unexpected)"
107
99
yield ValidationError (
@@ -276,11 +268,9 @@ def dependentSchemas(validator, dependentSchemas, instance, schema):
276
268
for property , dependency in dependentSchemas .items ():
277
269
if property not in instance :
278
270
continue
279
-
280
- for error in validator .descend (
271
+ yield from validator .descend (
281
272
instance , dependency , schema_path = property ,
282
- ):
283
- yield error
273
+ )
284
274
285
275
286
276
def enum (validator , enums , instance , schema ):
@@ -296,15 +286,13 @@ def ref(validator, ref, instance, schema):
296
286
resolve = getattr (validator .resolver , "resolve" , None )
297
287
if resolve is None :
298
288
with validator .resolver .resolving (ref ) as resolved :
299
- for error in validator .descend (instance , resolved ):
300
- yield error
289
+ yield from validator .descend (instance , resolved )
301
290
else :
302
291
scope , resolved = validator .resolver .resolve (ref )
303
292
validator .resolver .push_scope (scope )
304
293
305
294
try :
306
- for error in validator .descend (instance , resolved ):
307
- yield error
295
+ yield from validator .descend (instance , resolved )
308
296
finally :
309
297
validator .resolver .pop_scope ()
310
298
@@ -318,13 +306,11 @@ def dynamicRef(validator, dynamicRef, instance, schema):
318
306
with validator .resolver .resolving (lookup_url ) as subschema :
319
307
if ("$dynamicAnchor" in subschema
320
308
and fragment == subschema ["$dynamicAnchor" ]):
321
- for error in validator .descend (instance , subschema ):
322
- yield error
309
+ yield from validator .descend (instance , subschema )
323
310
break
324
311
else :
325
312
with validator .resolver .resolving (dynamicRef ) as subschema :
326
- for error in validator .descend (instance , subschema ):
327
- yield error
313
+ yield from validator .descend (instance , subschema )
328
314
329
315
330
316
def type (validator , types , instance , schema ):
@@ -341,13 +327,12 @@ def properties(validator, properties, instance, schema):
341
327
342
328
for property , subschema in properties .items ():
343
329
if property in instance :
344
- for error in validator .descend (
330
+ yield from validator .descend (
345
331
instance [property ],
346
332
subschema ,
347
333
path = property ,
348
334
schema_path = property ,
349
- ):
350
- yield error
335
+ )
351
336
352
337
353
338
def required (validator , required , instance , schema ):
@@ -372,8 +357,7 @@ def maxProperties(validator, mP, instance, schema):
372
357
373
358
def allOf (validator , allOf , instance , schema ):
374
359
for index , subschema in enumerate (allOf ):
375
- for error in validator .descend (instance , subschema , schema_path = index ):
376
- yield error
360
+ yield from validator .descend (instance , subschema , schema_path = index )
377
361
378
362
379
363
def anyOf (validator , anyOf , instance , schema ):
@@ -423,12 +407,10 @@ def if_(validator, if_schema, instance, schema):
423
407
if validator .is_valid (instance , if_schema ):
424
408
if "then" in schema :
425
409
then = schema ["then" ]
426
- for error in validator .descend (instance , then , schema_path = "then" ):
427
- yield error
410
+ yield from validator .descend (instance , then , schema_path = "then" )
428
411
elif "else" in schema :
429
412
else_ = schema ["else" ]
430
- for error in validator .descend (instance , else_ , schema_path = "else" ):
431
- yield error
413
+ yield from validator .descend (instance , else_ , schema_path = "else" )
432
414
433
415
434
416
def unevaluatedItems (validator , unevaluatedItems , instance , schema ):
@@ -469,7 +451,6 @@ def prefixItems(validator, prefixItems, instance, schema):
469
451
return
470
452
471
453
for k , v in enumerate (instance [:min (len (prefixItems ), len (instance ))]):
472
- for error in validator .descend (
454
+ yield from validator .descend (
473
455
v , prefixItems [k ], schema_path = "prefixItems" ,
474
- ):
475
- yield error
456
+ )
0 commit comments