-
Notifications
You must be signed in to change notification settings - Fork 14
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
Question, is there any plans, interest regarding AoT support? #12
Comments
Hi, thanks for the issue! I think any style improving changes would be nice to have. That said, the biggest goal of this package for me is having exactly 0 bugs. A simpler style (and fewer lines of code) make that a more realistic goal. I won't be working on this myself. If someone else does, I'll consider merging it if it doesn't add too much complexity, is well tested, and seems 100% bug free. Generally I'd advise using |
Inline tables are a cool feature of the TOML, and very useful as elements of an array. However there are some circumstances that they are explicitly discouraged by spec itself. For example when dumping a list of dicts that in turn have lists inside of them, `tomli-w` will introduce line breaks inside of inline tables, which is not recommended by the spec This situation was first described in issue hukkin#12. Please notice this usage pattern is not that uncommon. We can find examples of this nesting in the wild, like the ones used in `mypy` configuration: https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml-file
* Adds minimal support for Array of Tables (AoT) Inline tables are a cool feature of the TOML, and very useful as elements of an array. However there are some circumstances that they are explicitly discouraged by spec itself. For example when dumping a list of dicts that in turn have lists inside of them, `tomli-w` will introduce line breaks inside of inline tables, which is not recommended by the spec This situation was first described in issue #12. Please notice this usage pattern is not that uncommon. We can find examples of this nesting in the wild, like the ones used in `mypy` configuration: https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml-file * Account for more complicated AoT nesting * Remove unnecessary logic condition grouping * Apply suggestions from code review Co-authored-by: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com> * Update tomli_w/_writer.py * Revert check to not-all instead of any-not There might be a chance any-not is slightly more costly than not-all (although if it exists, the performance difference should be negligible) * Simplify is_suitable_inline_table condition * Add test for empty array * Satisfy typechecker concern about booleans * Remove unused 'name' arg from 'is_suitable_inline_table' * Make line length calculation more precise * Update tomli_w/_writer.py Co-authored-by: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com>
AoT support added in #15 Thanks @abravalheri |
Hello, thank you very much for the package!
I was wondering if
tomli-w
hasArray of Tables
(AoT) support (or at least if you consider this feature something nice to have in the roadmap).For example, if we take the following conversion:
The output looks very weird, and a AoT would make it much easier to read... I had to check the standards to believe it is not following a wrong syntax 😝 (it is explicitly discouraged to have line breaks inside inline tables, though)
In the case AoT is supported, the following would read much nicer:
In can see that currently nested tables are automatically handled:
which conceptually is not very different from AoT, right?
The text was updated successfully, but these errors were encountered: