We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
This is almost a drop-in replacement for the toml library. But an issue I ran into is lack of support for tuples, which toml converts to lists.
toml
In[50]: import toml In[51]: import tomlkit In[52]: x={'section': {'tuple_value': (1,2)}} In[53]: tomlkit.dumps(x) Out[53]: Traceback (most recent call last): File "C:\projects\foo\.venv\lib\site-packages\IPython\core\interactiveshell.py", line 3457, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "<ipython-input-53-add147bf2e5e>", line 1, in <module> tomlkit.dumps(x) File "C:\projects\foo\.venv\lib\site-packages\tomlkit\api.py", line 49, in dumps data = item(dict(data), _sort_keys=sort_keys) File "C:\projects\foo\.venv\lib\site-packages\tomlkit\items.py", line 92, in item val[k] = item(v, _parent=val, _sort_keys=_sort_keys) File "C:\projects\foo\.venv\lib\site-packages\tomlkit\items.py", line 92, in item val[k] = item(v, _parent=val, _sort_keys=_sort_keys) File "C:\projects\foo\.venv\lib\site-packages\tomlkit\items.py", line 152, in item raise ValueError(f"Invalid type {type(value)}") ValueError: Invalid type <class 'tuple'> In[54]: toml.dumps(x) Out[54]: '[section]\ntuple_value = [ 1, 2,]\n'
I think the way the toml library handles this is there's a fall back method that converts unrecognized iterables to lists, and so that catches tuples.
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
This is almost a drop-in replacement for the toml library. But an issue I ran into is lack of support for tuples, which
toml
converts to lists.I think the way the toml library handles this is there's a fall back method that converts unrecognized iterables to lists, and so that catches tuples.
The text was updated successfully, but these errors were encountered: