python-poetry / tomlkit

Style-preserving TOML library for Python
MIT License
699 stars 100 forks source link

Multiline array option for `dumps` #385

Open dbohdan opened 2 weeks ago

dbohdan commented 2 weeks ago

It would be useful for my project Remarshal and likely for other downstream users of TOML Kit to be able to tell toml.dumps to output multiline arrays. For example, you could call toml.dumps(foo, multiline=True) for only multiline arrays, call toml.dumps(foo, multiline=5) and make arrays with five or more items multiline, or have it based on the line length. Without this feature, you either get output like my TOML example or have to construct the document manually.

The option could also apply to inline tables if a future TOML spec added them.