-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested tables should be written below their parent table #88
Labels
component: encoder
Related to serialising in `toml.dump`
syntax: tables
Related to tables
type: feature
A self-contained enhancement or new feature
Comments
We can use dump order strategies for this. e.g. toml.dumps(data, nested_order=toml.NESTED_FIRST) # As suggested in this PR.
toml.dumps(data, nested_order=toml.NESTED_LAST) # Default/current strategy |
bochecha
added a commit
to bochecha/toml
that referenced
this issue
Jan 6, 2020
Currently, we first print all tables at the top level, then all nested tables at the second level, etc… As a result, this: { 'table1': { 'foo': 1, 'nested': { 'bar': 2, }, }, 'table2': { 'baz': 3, }, } … gets printed as: [table1] foo = 1 [table2] baz = 3 [table1.nested] bar = 2 With this commit, we print the nested tables with their parent, so the same example from above will instead become: [table1] foo = 1 [table1.nested] bar = 2 [table2] baz = 3 Fixes uiri#88
bochecha
added a commit
to bochecha/toml
that referenced
this issue
Jan 6, 2020
Currently, we first print all tables at the top level, then all nested tables at the second level, etc… As a result, this: { 'table1': { 'foo': 1, 'nested': { 'bar': 2, }, }, 'table2': { 'baz': 3, }, } … gets printed as: [table1] foo = 1 [table2] baz = 3 [table1.nested] bar = 2 With this commit, we print the nested tables with their parent, so the same example from above will instead become: [table1] foo = 1 [table1.nested] bar = 2 [table2] baz = 3 Fixes uiri#88
The v1.0.0 rc has a preferred ordering: https://toml.io/en/v1.0.0-rc.3#table
# VALID BUT DISCOURAGED
[fruit.apple]
[animal]
[fruit.orange] # RECOMMENDED
[fruit.apple]
[fruit.orange]
[animal] I support the approach in #275. |
pradyunsg
added
component: encoder
Related to serialising in `toml.dump`
type: feature
A self-contained enhancement or new feature
syntax: tables
Related to tables
and removed
user-customization
labels
Apr 20, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
component: encoder
Related to serialising in `toml.dump`
syntax: tables
Related to tables
type: feature
A self-contained enhancement or new feature
Though not a requirement of the spec, it would be a very nice feature of this library to, when encoding nested dictionaries, write nested tables directly below their parent table, instead of first all top-level sections then the next level, then the next.
The text was updated successfully, but these errors were encountered: