From 87135f99f1c5544263380c560b85718db005a120 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Mon, 20 Nov 2023 09:45:28 -0700 Subject: [PATCH] fixups: Drop supporting 2nd form of int array encoding Since dropping YAML encoded DTs, there's now only one encoding of arrays which is [[ 1, 2, 3 ]]. Therefore the fixup to support both forms can be dropped. The fixup now makes the outer array 1 item and minItems/maxItems in the schema always applies to the inner array. Signed-off-by: Rob Herring --- dtschema/fixups.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/dtschema/fixups.py b/dtschema/fixups.py index efda595..b6ce766 100644 --- a/dtschema/fixups.py +++ b/dtschema/fixups.py @@ -108,7 +108,6 @@ def is_int_array_schema(subschema, path=[]): # Fixup an int array that only defines the number of items. -# In this case, we allow either form [[ 0, 1, 2]] or [[0], [1], [2]] def _fixup_int_array_min_max_to_matrix(subschema, path=[]): if not is_int_array_schema(subschema, path=path): return @@ -136,17 +135,8 @@ def _fixup_int_array_min_max_to_matrix(subschema, path=[]): tmpsch['maxItems'] = subschema.pop('maxItems') if tmpsch: - subschema['oneOf'] = [copy.deepcopy(tmpsch), {'items': [copy.deepcopy(tmpsch)]}] - subschema['oneOf'][0].update({'items': {'maxItems': 1}}) - - # if minItems can be 1, then both oneOf clauses can be true so increment - # minItems in one clause to prevent that. - if subschema['oneOf'][0].get('minItems') == 1: - subschema['oneOf'][0]['minItems'] += 1 - - # Since we added an 'oneOf' the tree walking code won't find it and we need to do fixups - _fixup_items_size(subschema['oneOf']) - + subschema['items'] = tmpsch + subschema['maxItems'] = 1 def _fixup_remove_empty_items(subschema): if 'items' not in subschema: