You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support complex values (dicts/lists) in upsert and replace #18
Currently, Document.upsert() and Document.replace() only accept scalar values (strings, ints, floats, bools, null). Passing a dict or list raises:
yamltrip.errors.PatchError: input is not valid YAML
This forces consumers to implement workarounds like:
Manually serializing the complex value to YAML text
Removing the key with prune_remove
Concatenating the serialized text onto the remaining document
Re-parsing with yamltrip.loads()
This document-rebuild approach loses the round-tripping benefits of yamltrip (e.g. comments on the replaced value are lost, and formatting may change).
Complex values should be serialized in block style and inserted/replaced at the correct indentation level, preserving comments and formatting on other keys in the document.
Use Case
In usethis-python, we manage .pre-commit-config.yaml files where the
epos\ key contains a list of dicts. Operations like adding/removing hooks require setting
epos\ to a new list of complex repo configurations. Without complex value support, we're forced to rebuild documents from scratch, losing inline comments.
Activity
Add xfail test for comment preservation on partial hook removal
feat: support complex values (dicts/lists) in Replace operations
Support complex values (dicts/lists) in replace and upsert
Support complex values (dicts/lists) in replace and upsert (#19)