Open eyeseast opened 2 years ago
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
tomllib
in 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:
tomllib
but make the TOMLHandler
read-only by default. In that case, you could read TOML but would have to write in another format, unless you install another library (probably tomli_w
).tomli_w
as a dependency. That preserves current functionality, maybe extends it a bit, but adds a dependency.tomli_w
to use TOMLHandler
. Again, basically the same as now, but with a different optional dependency.I don't use TOML enough to have a strong opinion here. Would like to hear from people who use the current TOML support.
My suggestion: Add tomli_w
as a dependency, and tomli
as a dependency for when Python version is < 3.11
Something like this:
install_requires =
tomli==1.2.3; python_version < 3.11
tomli-w==1.2.3
And in your Python code:
import tomli_w
if sys.version_info() >= (3, 11):
import tomllib as tomli
else:
import tomli
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.