Skip to content

Commit d2c9847

Browse files
committed
Codegen: parse synth property modifier
1 parent 165ac3e commit d2c9847

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

misc/codegen/lib/schemadefs.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,15 @@ def __init__(self, **kwargs):
4444
self.__dict__.update(kwargs)
4545

4646

47+
class _SynthModifier(_schema.PropertyModifier, _Namespace):
48+
def modify(self, prop: _schema.Property):
49+
prop.synth = True
50+
51+
4752
qltest = _Namespace()
4853
ql = _Namespace()
4954
cpp = _Namespace()
50-
synth = _Namespace()
55+
synth = _SynthModifier()
5156

5257

5358
@_dataclass

misc/codegen/test/test_schemaloader.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,17 @@ class C(Root):
455455
}
456456

457457

458+
def test_synthesized_property():
459+
@load
460+
class data:
461+
class A:
462+
x: defs.int | defs.synth
463+
464+
assert data.classes["A"].properties == [
465+
schema.SingleProperty("x", "int", synth=True)
466+
]
467+
468+
458469
def test_class_docstring():
459470
@load
460471
class data:

0 commit comments

Comments
 (0)