pyconfs icon indicating copy to clipboard operation
pyconfs copied to clipboard

Bug: TOML Pretty print doesn't handle nesting properly

Open gahjelle opened this issue 3 years ago • 0 comments

Example:

>>> from pyconfs import Configuration
>>> cfg = Configuration.from_dict({"a": {"b": {"c": 3}, "d": 4}})

>>> Configuration.from_str(cfg.as_str(format="toml", pretty_print=False), format="toml").as_dict()
{'a': {'d': 4, 'b': {'c': 3}}}

>>> Configuration.from_str(cfg.as_str(format="toml", pretty_print=True), format="toml").as_dict()
{'a': {'b': {'c': 3, 'd': 4}}}

Note that in the final example, d is an entry inside a.b, while originally it was an entry in a.

The problem is that the pretty printer doesn't take into account the order of keys in a section. It should probably list all entries before sections.

gahjelle avatar Nov 22 '21 09:11 gahjelle