python-frontmatter
python-frontmatter copied to clipboard
Use tomli in TOML handler
Looks like this is the new standard: https://pypi.org/project/tomli/
Need to check if this has the same API as the original toml. It might be worth creating an additional TOML handler using tomli, so you can import each one separately.
As noted here, I should add an extra so you can do pip install python-frontmatter[toml] (or [tomli]) and get everything in one shot.
FYI Python is gaining tomllib in the 3.11 standard library, which is adapted from tomli
FYI Python is gaining
tomllibin the 3.11 standard library, which is adapted fromtomli
tomli is also a good choice, not only because of the reason you mentioned, it's implemented in pure python. If we don't need .load() or .loads(), which is implemented in a different package (tomli_w), then I am not against tomli here.
With Python 3.11 now available this feels like a higher priority. Since tomllib is read-only, I need to think about how to include it. Some options, in no particular order:
- Use
tomllibbut make theTOMLHandlerread-only by default. In that case, you could read TOML but would have to write in another format, unless you install another library (probablytomli_w). - Add
tomli_was a dependency. That preserves current functionality, maybe extends it a bit, but adds a dependency. - Require
tomli_wto useTOMLHandler. Again, basically the same as now, but with a different optional dependency. - Use tomlkit to get reading and writing and also preserve format.
I don't use TOML enough to have a strong opinion here. Would like to hear from people who use the current TOML support.