@@ -237,9 +237,6 @@ def maybe_in_subresource(
237
237
subresource : Resource [Any ],
238
238
) -> _Resolver [Any ]:
239
239
_segments = iter (segments )
240
- # FIXME: This is a ton of redone work, each time we recheck from the
241
- # beginning of the pointer, so long ones will just keep doing
242
- # that over and over again...
243
240
for segment in _segments :
244
241
if segment not in in_value and (
245
242
segment not in in_child or next (_segments , None ) is None
@@ -250,6 +247,60 @@ def maybe_in_subresource(
250
247
return maybe_in_subresource
251
248
252
249
250
+ def _maybe_in_subresource_crazy_items (
251
+ in_value : Set [str ] = frozenset (),
252
+ in_subvalues : Set [str ] = frozenset (),
253
+ in_subarray : Set [str ] = frozenset (),
254
+ ):
255
+ in_child = in_subvalues | in_subarray
256
+
257
+ def maybe_in_subresource (
258
+ segments : Sequence [int | str ],
259
+ resolver : _Resolver [Any ],
260
+ subresource : Resource [Any ],
261
+ ) -> _Resolver [Any ]:
262
+ _segments = iter (segments )
263
+ for segment in _segments :
264
+ if segment == "items" and isinstance (
265
+ subresource .contents , Mapping
266
+ ):
267
+ return resolver .in_subresource (subresource )
268
+ if segment not in in_value and (
269
+ segment not in in_child or next (_segments , None ) is None
270
+ ):
271
+ return resolver
272
+ return resolver .in_subresource (subresource )
273
+
274
+ return maybe_in_subresource
275
+
276
+
277
+ def _maybe_in_subresource_crazy_items_dependencies (
278
+ in_value : Set [str ] = frozenset (),
279
+ in_subvalues : Set [str ] = frozenset (),
280
+ in_subarray : Set [str ] = frozenset (),
281
+ ):
282
+ in_child = in_subvalues | in_subarray
283
+
284
+ def maybe_in_subresource (
285
+ segments : Sequence [int | str ],
286
+ resolver : _Resolver [Any ],
287
+ subresource : Resource [Any ],
288
+ ) -> _Resolver [Any ]:
289
+ _segments = iter (segments )
290
+ for segment in _segments :
291
+ if (
292
+ segment == "items" or segment == "dependencies"
293
+ ) and isinstance (subresource .contents , Mapping ):
294
+ return resolver .in_subresource (subresource )
295
+ if segment not in in_value and (
296
+ segment not in in_child or next (_segments , None ) is None
297
+ ):
298
+ return resolver
299
+ return resolver .in_subresource (subresource )
300
+
301
+ return maybe_in_subresource
302
+
303
+
253
304
DRAFT202012 = Specification (
254
305
name = "draft2020-12" ,
255
306
id_of = _dollar_id ,
@@ -325,7 +376,7 @@ def maybe_in_subresource(
325
376
},
326
377
),
327
378
anchors_in = _anchor_2019 ,
328
- maybe_in_subresource = _maybe_in_subresource (
379
+ maybe_in_subresource = _maybe_in_subresource_crazy_items (
329
380
in_value = {
330
381
"additionalItems" ,
331
382
"additionalProperties" ,
@@ -366,7 +417,7 @@ def maybe_in_subresource(
366
417
in_subvalues = {"definitions" , "patternProperties" , "properties" },
367
418
),
368
419
anchors_in = _legacy_anchor_in_dollar_id ,
369
- maybe_in_subresource = _maybe_in_subresource (
420
+ maybe_in_subresource = _maybe_in_subresource_crazy_items_dependencies (
370
421
in_value = {
371
422
"additionalItems" ,
372
423
"additionalProperties" ,
@@ -396,7 +447,7 @@ def maybe_in_subresource(
396
447
in_subvalues = {"definitions" , "patternProperties" , "properties" },
397
448
),
398
449
anchors_in = _legacy_anchor_in_dollar_id ,
399
- maybe_in_subresource = _maybe_in_subresource (
450
+ maybe_in_subresource = _maybe_in_subresource_crazy_items_dependencies (
400
451
in_value = {
401
452
"additionalItems" ,
402
453
"additionalProperties" ,
@@ -417,7 +468,7 @@ def maybe_in_subresource(
417
468
in_subvalues = {"definitions" , "patternProperties" , "properties" },
418
469
),
419
470
anchors_in = _legacy_anchor_in_id ,
420
- maybe_in_subresource = _maybe_in_subresource (
471
+ maybe_in_subresource = _maybe_in_subresource_crazy_items_dependencies (
421
472
in_value = {"additionalItems" , "additionalProperties" , "not" },
422
473
in_subarray = {"allOf" , "anyOf" , "oneOf" },
423
474
in_subvalues = {"definitions" , "patternProperties" , "properties" },
@@ -432,7 +483,7 @@ def maybe_in_subresource(
432
483
in_subvalues = {"definitions" , "patternProperties" , "properties" },
433
484
),
434
485
anchors_in = _legacy_anchor_in_id ,
435
- maybe_in_subresource = _maybe_in_subresource (
486
+ maybe_in_subresource = _maybe_in_subresource_crazy_items_dependencies (
436
487
in_value = {"additionalItems" , "additionalProperties" },
437
488
in_subarray = {"extends" },
438
489
in_subvalues = {"definitions" , "patternProperties" , "properties" },
0 commit comments