dumps(sort_keys) does not seem to work for parsed TOML documents:
>>> tomlkit.dumps(tomlkit.loads('zzz = 1\naaa = "foo"'), sort_keys=True)
'zzz = 1\naaa = "foo"'
It works fine on regular objects, as far as I can tell:
>>> tomlkit.dumps({'zzz': 1, 'aaa': "foo"}, sort_keys=True)
'aaa = "foo"\nzzz = 1\n'
It does work when I manually apply the item(_sort_keys) wrapping done in the API:
>>> tomlkit.dumps(tomlkit.item(tomlkit.loads('zzz = 1\naaa = "foo"'), _sort_keys=True))
'aaa = "foo"\nzzz = 1\n'
I believe it's because the condition doesn't trigger since tomlkit.loads returns a TOMLDocument:
>>> x = tomlkit.loads('zzz = 1\naaa = "foo"')
>>> type(x)
<class 'tomlkit.toml_document.TOMLDocument'>
>>> isinstance(x, tomlkit.container.Container)
True
dumps(sort_keys)does not seem to work for parsed TOML documents:It works fine on regular objects, as far as I can tell:
It does work when I manually apply the
item(_sort_keys)wrapping done in the API:I believe it's because the condition doesn't trigger since
tomlkit.loadsreturns aTOMLDocument: