validator: Fix missing '#' stripping from schema ID#192
Merged
Conversation
Schema IDs contain a trailing '#' which is stripped to create a key to
index the schemas dictionary. Stripping is missing in one location,
which causes a KeyError exception when a property mixes multiple types:
Traceback (most recent call last):
File "~/.local/bin/dt-mk-schema", line 6, in <module>
sys.exit(main())
~~~~^^
File "~/src/tools/dt-schema/dtschema/mk_schema.py", line 28, in main
schemas = dtschema.DTValidator(args.schemas).schemas
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
File "~/src/tools/dt-schema/dtschema/validator.py", line 399, in __init__
self.make_property_type_cache()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "~/src/tools/dt-schema/dtschema/validator.py", line 528, in make_property_type_cache
self.check_duplicate_property_types()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "~/src/tools/dt-schema/dtschema/validator.py", line 522, in check_duplicate_property_types
print(f"{self.schemas[sch_id]['$filename']}: {p}: multiple incompatible types: {v['type']}", file=sys.stderr)
~~~~~~~~~~~~^^^^^^^^
KeyError: 'http://devicetree.org/schemas/crypto/fsl,sec-v4.0.yaml#'
Fix it by stripping the trailing '#' like done in other locations.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Schema IDs contain a trailing '#' which is stripped to create a key to index the schemas dictionary. Stripping is missing in one location, which causes a KeyError exception when a property mixes multiple types:
Traceback (most recent call last):
File "
/.local/bin/dt-mk-schema", line 6, in/src/tools/dt-schema/dtschema/mk_schema.py", line 28, in mainsys.exit(main())
~~~~^^
File "
schemas = dtschema.DTValidator(args.schemas).schemas
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
File "
/src/tools/dt-schema/dtschema/validator.py", line 399, in init/src/tools/dt-schema/dtschema/validator.py", line 528, in make_property_type_cacheself.make_property_type_cache()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "
self.check_duplicate_property_types()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "~/src/tools/dt-schema/dtschema/validator.py", line 522, in check_duplicate_property_types
print(f"{self.schemas[sch_id]['$filename']}: {p}: multiple incompatible types: {v['type']}", file=sys.stderr)
~~~~~~~~~~~~^^^^^^^^
KeyError: 'http://devicetree.org/schemas/crypto/fsl,sec-v4.0.yaml#'
Fix it by stripping the trailing '#' like done in other locations.