Skip to content

Commit 00b59f8

Browse files
committed
Codegen: disallow child on set properties
1 parent 442e850 commit 00b59f8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

misc/codegen/lib/schemadefs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class _ChildModifier(_schema.PropertyModifier):
88
def modify(self, prop: _schema.Property):
99
if prop.type is None or prop.type[0].islower():
1010
raise _schema.Error("Non-class properties cannot be children")
11+
if prop.is_unordered:
12+
raise _schema.Error("Set properties cannot be children")
1113
prop.is_child = True
1214

1315

misc/codegen/test/test_schemaloader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ class A:
259259
}
260260

261261

262-
@pytest.mark.parametrize("spec", [defs.string, defs.int, defs.boolean, defs.predicate])
263-
def test_builtin_and_predicate_children_not_allowed(spec):
262+
@pytest.mark.parametrize("spec", [defs.string, defs.int, defs.boolean, defs.predicate, defs.set["A"]])
263+
def test_builtin_predicate_and_set_children_not_allowed(spec):
264264
with pytest.raises(schema.Error):
265265
@load
266266
class data:

0 commit comments

Comments
 (0)