Skip to content

Commit

Permalink
fixups: Allow "items" entries to be boolean
Browse files Browse the repository at this point in the history
Empty schemas are allowed, so a boolean should be as well.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
  • Loading branch information
robherring committed Nov 1, 2024
1 parent 0983463 commit c9b4797
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dtschema/fixups.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def _fixup_remove_empty_items(subschema):
return

for item in subschema['items']:
if not isinstance(item, dict):
continue
item.pop('description', None)
_fixup_remove_empty_items(item)
if item != {}:
Expand Down
4 changes: 4 additions & 0 deletions dtschema/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def _value_is_type(subschema, key, type):


def _is_int_schema(subschema):
if not isinstance(subschema, dict):
return False
for match in ['const', 'enum', 'minimum', 'maximum']:
if _value_is_type(subschema, match, int):
return True
Expand All @@ -41,6 +43,8 @@ def _is_int_schema(subschema):


def _is_string_schema(subschema):
if not isinstance(subschema, dict):
return False
for match in ['const', 'enum', 'pattern']:
if _value_is_type(subschema, match, str):
return True
Expand Down
1 change: 1 addition & 0 deletions test/schemas/good-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ properties:
- enum:
- vendor,soc1-ip
- items:
- false
- not: {}
description: Needs a specific compatible
- const: vendor,soc1-ip
Expand Down

0 comments on commit c9b4797

Please sign in to comment.