SafeConstructor.yaml_flatteners, to enable pluggable flattening akin to add_constructors#894
SafeConstructor.yaml_flatteners, to enable pluggable flattening akin to add_constructors#894
Conversation
…to add_constructors
|
Not specifically related to this PR, but I'd lean towards |
|
Well, then again, if pyyaml offered a |
|
I have no preference and haven't implemented anything "real" on the octoDNS side yet. Only testing out what I've been playing around with here. I've pushed up a test case for the simplest path. Looking at the details of supporting things like: foo:
<<: [!custom ..., !custom, ...]Now as the current implementation doesn't support them. |
|
Ok. Fixed the sequence case so that it will also handle custom flatteners. Was a trivial change and it actually works much more like map now so that's probably an added benefit. Test cases for the original handling of maps in sequences along with custom flatteners added as well. Going to move this out of draft as I believe it's now at least to the point where it's ready for 👀 and 💭s |
|
Out of time for today, but I'll try to follow up more tomorrow. |
…y wins, more complete ordering tests
As part of working through octodns/octodns#1315 I wanted to add support for
<<: !include some-file.yamland ran into the same problems as others: #632 and #814.After a few false starts and unworkable ideas I landed on adding the ability to have pluggable flattening the same way that constructors are now. It's a fairly trivial change in the repo and I'm able to port the existing map and seq blocks over and have all the tests passing.
More interestingly it allows 3rd parties to add new flatteners, so in the case of
!includeI can do something like:In the context of octoDNS that allows config like:
To work exactly as expected.
I'm out of time for now, but I plan to come back to this PR and look at adding specific tests around the ability to add custom flatteners and verify that the more complex versions of
<<:work, i.e. arrays and custom flatterers in anchors.Thoughts and suggestions welcomed.