-
-
Notifications
You must be signed in to change notification settings - Fork 112
sort_keys does not (always?) work #466
Copy link
Copy link
Open
Description
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)
TrueReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels