Conversation
Swap the TOML reader/writer for tomlrt: - tomlkit.parse / tomlkit.dumps become tomlrt.load / tomlrt.dump - tomlkit.exceptions.NonExistentKey becomes a plain KeyError - add_section uses Document.ensure_table, replacing the hand-rolled descent loop, and reports a clean error instead of a traceback when a path component cannot be descended through - tomlrt returns plain str / int / bool, so the hasattr(x, "unwrap") guard in `get` is no longer needed Read and write in binary mode. Toml is always utf-8, but read_text() and write_text() use the locale encoding, which crashes on non-ascii content under a non-utf-8 locale, and would rewrite CRLF line endings to LF. Fixes mrijken#37. Two test assertions change, both cosmetic: tomlrt emits a blank line before a new section header, and removing the last key leaves an empty file rather than a stray newline. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dimbleby
force-pushed
the
migrate-to-tomlrt
branch
from
August 15, 2026 21:15
3815a7f to
eb54633
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi -
I have been writing tomlrt, which occupies roughly the same space as tomlkit - but hopefully has a simpler API, fewer bugs, better performance.
Honestly tomlkit looks as though it probably is mostly fine here, do just close this out if you are happy enough with it.
What I expect you get from this PR is
unwrap(),ensure_table()is a convenience, standard exceptions)all of which is perhaps not a lot; and it is always possible that future tomlkit versions will be faster and fix bugs anyway.
But since I have performed the experiment, I thought I would offer it to you.
Swap the TOML reader/writer for tomlrt:
getis no longer neededRead and write in binary mode. Toml is always utf-8, but read_text() and write_text() use the locale encoding, which crashes on non-ascii content under a non-utf-8 locale, and would rewrite CRLF line endings to LF. Fixes #37.
Two test assertions change, both cosmetic: tomlrt emits a blank line before a new section header, and removing the last key leaves an empty file rather than a stray newline.