Closed dbowring closed 3 years ago
In other words, what would return falsy dicts and lists instead returns None
.
This has... some legitimacy: all of [], {}, None
are falsy, so namedtext.load(...) or default
should be fine. However dict.update
and other methods would be a little bit of a headache here.
I would therefore recommend the data type be as given, with None
only for falsy input eg nestedtext.loads('')
.
This looks like a bug in dump. Give me some time to look into it.
Upon further review, this is not a bug at all. Rather it is a rather unexpected consequence of the design decision that all leaf values must be strings. At the moment I don't see that changing.
The current behavior of NestedText is consisted with the idea that you use NestedText files to hold the values without any information about the type of those values. Instead it is up to the end application to know what type to expect for a particular value and do the conversion itself. Fortunately, one can use voluptuous to do easily do the conversion.
It turns out that this report did uncover a bug. dump() should not allow empty dictionaries and lists when default='strict' is specified. That will be corrected.
Very interested in this as a yaml alternative, but this would be a blocker for me.