Clarification on type annotations in encoded output #232
-
Hello all, Regarding type annotations, the spec states:
Given that, I would not necessarily expect encoded output to have to retain type annotations for values. However, it looks like there are a number of test cases whose encoded output does contain the type annotation. My question is: are implementations required to retain type annotation information for encoding? Or are the tests perhaps outdated? FWIW, the rust and JS implementations do not seem to pass these tests, but maybe they just haven't implemented this behavior yet. Many examples in this commit. One example here: input:
output:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Yes, type annotations are part of the data model. Impls just don't have to do anything with them; they can treat the node/value exactly like normal otherwise. |
Beta Was this translation helpful? Give feedback.
-
Yes, you need to preserve the tag with a custom class in this case. https://github.com/tabatkins/kdlpy does this, for instance - by default it'll parse untagged values into native Python types, but tagged values become lib-specific types. |
Beta Was this translation helpful? Give feedback.
-
kdl4j retains them and round trips them, but currently they aren't used internally. |
Beta Was this translation helpful? Give feedback.
Yes, type annotations are part of the data model. Impls just don't have to do anything with them; they can treat the node/value exactly like normal otherwise.