schema: fix canvas/dock child layout properties - #548
Conversation
|
Do we need error cases so we see if pack-checker fails validation properly? |
|
I mean error case would be as simple to add an additional property, and maybe check that the something like the dock property only validates on children of dock layouts. if dock works canvas is likely also work as it's implemented in the same way. As I said I didn't test against pack-checker, I only really checked the results in vs code because that was quickest way to test. |
|
It appears to do the right thing in pack checker, but the error message is pretty bad. I added a "dock": "left" to the outermost dock of the template_pack (and also to the first map, same output) and I got It doesn't say which property is the problem nor where the problem is. |
|
For completeness sake, with the old schema, an unknown property would look something like this: |
|
that might be an issue with the python from jsonschema import Draft202012Validator
with io.open(f"schema/packs/strict/{item.type}.json") as schema_file:
validator = Draft202012Validator(json.load(schema_file))
errors = list( validator.iter_errors(item.data))
for error in errors:
path = "/".join(str(p) for p in error.absolute_path) or "<root>"
print(f"{path}: {error.message}")I get I would assume that pack-checker or Either way I would still prefer this to be merged since it simplifies the schema while also actually correctly validating the properties now. |
|
I do want to merge this, but I feel like we need to figure this out because it makes other errors unreadable. :S
validate() should go through the registry, which should default to 202012 already if unspecified.
If I change the code in the pack-checker from validate(...) to schema = json.load(open(f".../strict/{item.type}.json"))
validator = Draft202012Validator(schema)
errors = list(validator.iter_errors(item.data))
for error in errors:
print(f"{error.message}")or if I run this snippet import io
import json
from jsonschema import Draft202012Validator
from typing import NamedTuple
class Item(NamedTuple):
type: str
data: str
item = Item("layouts", json.load(open(".../template_pack/layouts/tracker.jsonc")))
with io.open(f".../strict/{item.type}.json") as schema_file:
validator = Draft202012Validator(json.load(schema_file))
errors = list(validator.iter_errors(item.data))
for error in errors:
path = "/".join(str(p) for p in error.absolute_path) or "<root>"
print(f"{path}: {error.message}")I get the same I took the template pack, opened the tracker.jsonc, removed the 2 comments up top and changed the Map 1 map widget to include It appears that the layout root matches the wrong thing and fails if an inner node has a bad property. If I put the I tried with both py3.12 in my existing venv and py3.14 in a fresh venv where I only pip installed latest jsonschema. |
didn't test this in pack-checker so you might want to still do that
resolves PopTracker/pack-checker#58