-
-
Notifications
You must be signed in to change notification settings - Fork 105
Closed
Description
Following document looks like legit, but when I try to parse it I get tomlkit.exceptions.KeyAlreadyPresent: Key "scripts" already exists.
exception with tomlkit 0.7.2.
document
[tool.poetry]
[tool.isort]
[tool.poetry.dev-dependencies]
[build-system]
[tool.poetry.scripts]
stacktrace
Traceback (most recent call last):
File "/Users/ccilingi/prepos/tomlbug/tomltest.py", line 21, in <module>
regular_dict = dict(parsed)
File "/Users/ccilingi/Library/Caches/pypoetry/virtualenvs/tomlbug-EdMsyBII-py3.9/lib/python3.9/site-packages/tomlkit/container.py", line 559, in __getitem__
return OutOfOrderTableProxy(self, idx)
File "/Users/ccilingi/Library/Caches/pypoetry/virtualenvs/tomlbug-EdMsyBII-py3.9/lib/python3.9/site-packages/tomlkit/container.py", line 699, in __init__
self._internal_container.append(k, v)
File "/Users/ccilingi/Library/Caches/pypoetry/virtualenvs/tomlbug-EdMsyBII-py3.9/lib/python3.9/site-packages/tomlkit/container.py", line 169, in append
current.append(k, v)
File "/Users/ccilingi/Library/Caches/pypoetry/virtualenvs/tomlbug-EdMsyBII-py3.9/lib/python3.9/site-packages/tomlkit/items.py", line 922, in append
self._value.append(key, _item)
File "/Users/ccilingi/Library/Caches/pypoetry/virtualenvs/tomlbug-EdMsyBII-py3.9/lib/python3.9/site-packages/tomlkit/container.py", line 175, in append
raise KeyAlreadyPresent(key)
tomlkit.exceptions.KeyAlreadyPresent: Key "scripts" already exists.
code
You can run the following python script to reproduce:
from tomlkit import parse
import ast
from pprint import pprint
doc = """
[tool.poetry]
[tool.isort]
[tool.poetry.dev-dependencies]
[build-system]
[tool.poetry.scripts]
"""
parsed = parse(doc)
as_str = str(parsed)
eval_dict = ast.literal_eval(as_str)
pprint(eval_dict)
regular_dict = dict(parsed)
This is the contents of eval_dict
:
{'build-system': {},
'tool': {'isort': {}, 'poetry': {'dev-dependencies': {}, 'scripts': {}}}}
Metadata
Metadata
Assignees
Labels
No labels