Codegen: disallow child on set properties

This commit is contained in:
Paolo Tranquilli
2023-03-29 14:34:11 +02:00
parent 442e85099b
commit 00b59f83f2
2 changed files with 4 additions and 2 deletions

View File

@@ -8,6 +8,8 @@ class _ChildModifier(_schema.PropertyModifier):
def modify(self, prop: _schema.Property):
if prop.type is None or prop.type[0].islower():
raise _schema.Error("Non-class properties cannot be children")
if prop.is_unordered:
raise _schema.Error("Set properties cannot be children")
prop.is_child = True

View File

@@ -259,8 +259,8 @@ def test_children():
}
@pytest.mark.parametrize("spec", [defs.string, defs.int, defs.boolean, defs.predicate])
def test_builtin_and_predicate_children_not_allowed(spec):
@pytest.mark.parametrize("spec", [defs.string, defs.int, defs.boolean, defs.predicate, defs.set["A"]])
def test_builtin_predicate_and_set_children_not_allowed(spec):
with pytest.raises(schema.Error):
@load
class data: