lisa.wlgen.rta.leaf_precedence#
- lisa.wlgen.rta.leaf_precedence(val, **kwargs)[source]#
Give precedence to the leaf values when combining with
&
:phase = phase.with_props(meta=({'hello': 'leaf'}) phase = phase.with_props(meta=leaf_precedence({'hello': 'root'}) assert phase['meta'] == {'hello': 'leaf'}
This allows setting a property with some kind of default value on a root node in the phase tree while still allowing it to be combined with the children values in such a way that the children values take precedence.
Note
In order to make the result more predictable, the effect will not propagate beyond one level where the property is set. This means it will work best for properties that are only set in leaves only.