Skip to content
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

dotted keys with multiline strings #279

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

samuelcolvin
Copy link

I've added a test for this: toml-lang/toml-test#57

fix #265

The problem is that when you call currentlevel[pair[0]] = value on line 786, you've re-assigned currentlevel thus isn't not the same as where you were calling currentlevel[multikey] = value on line 395, this get's around that problem by returning a new multilevel object.

@puhitaku
Copy link

Thanks for the patch as I also suffered this problem.
I really want it to be merged soon... Could you consider merging this? @uiri

@samuelcolvin
Copy link
Author

I think this library is no longer properly maintained (although I know it's very widely used).

you might try rtoml which should fix this problem and many more (admission: I built rtoml).

@puhitaku
Copy link

That sounds great, wanna try this soon!
For a variety of TOML parser let me introduce that Poetry uses tomlkit for parsing TOML.

@samuelcolvin
Copy link
Author

https://github.com/samuelcolvin/rtoml/tree/master/benchmarks

Perhaps poetry likes life in the slow lane :-)

@gaborbernat
Copy link

@samuelcolvin does rtoml supports roundtrip guarantees e.g. dump(load(toml_text)) == toml_text?

@samuelcolvin
Copy link
Author

@samuelcolvin does rtoml supports roundtrip guarantees e.g. dump(load(toml_text)) == toml_text?

I don't think so, it'll be the same as toml-rs which it's based on.

@gaborbernat
Copy link

In that case your comparison is not fair, and you should probably remove it from the table. That feature is very important for poetry, and tools in general (that need to alter config files without modifying the formatting of the file). They're designed and optimized for different use case.

@samuelcolvin
Copy link
Author

I've just tried and rtoml definitely doesn't provide roundtrip guarantees. I don't know if that's a problem in the python or a characteristic of toml-rs (you would have though it would be necessary to load and write to Cargo.toml?).

I see the distinction, though for many applications it's not a problem. Happy to accept a PR to add a clarification to benchmarks.

By the way, I think (if I remember correctly) tomlkit also fails some of the standard toml tests. I can give details if necessary.

br3ndonland added a commit to br3ndonland/inboard that referenced this pull request Sep 16, 2021
https://toml.io/en/
uiri/toml#267
uiri/toml#279 (comment)

While the TOML spec is alive and well, the `toml` package that was used
in this project is dead (uiri/toml#267). There are several alternatives.
`rtoml` is the fastest, but does not provide "round trip" guarantees
(meaning that it can't load, then dump, and get an identical result).
However, for simple loading and parsing it's fine. `tomli` is another
alternative, but it is read-only (writing requires a separate `tomli-w`
package), and requires files to be opened in binary mode to parse TOML.
`tomlkit` is used by Poetry (from the Poetry author), but is currently
70x slower than `rtoml`.

It's also important to note that the TOML parsing and settings loading
is somewhat tangential to the focus of the inboard project. A separate
project, https://github.com/br3ndonland/fastenv, is more focused on
settings management, and may feature TOML support in the future.

This commit will remove `toml` from the `fastapi` Poetry extras group.
Note that `toml` is still a sub-dependency of some `dev-dependencies`,
including pre-commit and pytest.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken parsing of triple-quoted strings with dotted keys
3 participants