PyO3 / pyproject-toml-rs

pyproject.toml parser in Rust
MIT License
19 stars 8 forks source link

Preserving pyproject.toml formatting #10

Open cnpryer opened 1 year ago

cnpryer commented 1 year ago

Description

Off the top of my head, I'm assuming this is more of an upstream toml behavior. I know there's a "preserve_order" feature, but I'm not certain if that fully addresses this issue. I'd be happy to move this upstream if that's where the fix needs to be made.

Right now as I understand it, there's no preservation of the toml file's original format, even with the "preserve_order" feature. I'm pretty certain that feature is meant for data structures like HashMap vs IndexMap, but it doesn't effect how a struct's attributes are ordered during its serialization.

Request

Preserve original formatting of the toml file. Could be feature-gated as well. Currently I personally only need table order preservation, but I plan to collect feedback on this over time (for my project) so that may change.


To be completely transparent, I have a few things I'd like to complete and then I'd be more than happy to work on this if you're okay with the change.

messense commented 1 year ago

Feel free to send PRs.

adamreichold commented 1 year ago

toml_edit which powers Cargo's modification features (and toml behind the scenes) might be be helpful for this.