Debian Codegraph @

context/data-tagging.md

raw
1 # Data tagging
2
3 ## How not to break things
4
5 Avoid unnecessary mutation of values, such as calling `str.strip` or `to_text`, etc. as these will drop tags, losing things like origin and trust for templating.
6
7 When mutation of a value is necessary, carefully consider which tags, if any, need to be propagated to the resulting value.
8
9 ## When tags must be removed
10
11 Some APIs don't understand tagged types and can't automatically treat them as their untagged equivalents.
12 This includes C-implemented Python APIs that perform exact type checks, serialization libraries that reject derived types,
13 and any interface where the consumer expects or requires plain types.
14 In these cases, use `transform_to_native_types()` from `ansible.utils.vars` to convert tagged values to native types before passing them to the API.