-
Notifications
You must be signed in to change notification settings - Fork 906
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
Replace toml
by stdlib counterparts for reading, evaluate options for writing
#3690
Comments
Notice that currently users of all versions of Python are forced to install a TOML-writing dependency just for |
Thank you for the detailed analysis, @astrojuanlu .
I agree with that. However, does this mean we need to adjust all instances of our reading code like that?:
It looks like we only update |
We could do this instead: try:
import tomllib # stdlib
except ImportError: # old Python versions
import tomli as tomllib and avoid changing the code itself |
Discussed this issue in grooming (11/3/2024) and we decided to close it for the time being because |
We use
toml
in exactly 3 modules, mostly for reading. In 1 place we are using it for writingkedro/kedro/templates/project/hooks/utils.py
Lines 94 to 95 in f56e4cc
TOML capabilities in Python are evolving and it would be good to adapt. On the other hand,
toml
, the library we use, was last updated in 2020 and is basically abandoned.First attempt: #2569 (comment)
Comes from: kedro-org/kedro-plugins#333 (comment)
Loading
Since Python 3.11, the standard library includes a native TOML library for reading files, https://docs.python.org/3/library/tomllib.html, which according to PEP 680 is based on https://pypi.org/project/tomli/
Therefore we could replace
toml
in our dependencies by something likeand remove that when we drop support for Python 3.10 (October 2026). This would save 1 dependency for Python >= 3.11.
Writing
After a long discussion it was decided to not include TOML writing capabilities in the standard library. There are 3 options for it:
tomlit works, but it's abandonware.It's likely that we want style-preserving capabilities, since our
kedro new
hooks modify stuff from the userpyproject.toml
. I have no idea what are the guarantees that currenttoml
provides.The text was updated successfully, but these errors were encountered: