unwrap raises KeyAlreadyPresent for an out-of-order AoT element extension
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
Research direction
Start by tracing tomlkit.parse(), doc["y"], doc.unwrap(), and the OutOfOrderTableProxy merge path described in the issue. Reproduce the supplied document and verify that accessing y and unwrapping no longer raises KeyAlreadyPresent while doc.as_string() still exactly matches the input.
Written by the indexing model from the issue text.
Description
Description
tomlkit.parse() accepts and exactly round-trips this valid document, but accessing doc["y"] or calling doc.unwrap() raises KeyAlreadyPresent: Key "a" already exists:
from tomlkit import parse
content = """\
[[y.a]]
[b.d.x]
[[y.a.c]]
"""
doc = parse(content)
assert doc.as_string() == content
doc.unwrap() # KeyAlreadyPresent: Key "a" already exists
Python's standard-library tomllib reads it as:
{"y": {"a": [{"c": [{}]}]}, "b": {"d": {"x": {}}}}
The later [[y.a.c]] header extends the last element of the existing y.a array of tables. This works when the parts are adjacent, but an unrelated table makes y out of order. OutOfOrderTableProxy then sees a first as an AoT and later as an implicit Table; its existing fragment merge handles AoT + AoT, but not this AoT + super-table extension.
The example was initially flagged by @chuenchen309 in the description of #565. I reproduced it on current master and narrowed it down to the proxy merge path.
Environment
- tomlkit 0.15.1 / current
master - Python 3.12
- Dominant language
- Python
- Stars
- 850
- Forks
- 163
- Avg merge
- 13m
- Merged PRs (30d)
- 2
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python-poetry/tomlkit
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
python-poetry/tomlkit#546 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
python-poetry/tomlkit#603 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
python-poetry/tomlkit#580 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
python-poetry/tomlkit#574 · 5 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
python-poetry/tomlkit#571 ·
All issues in python-poetry/tomlkit
Similar issues
-
essnmx good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
[Feature] 奇物选择添加优先级 Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
syfoud/Simulated_Scepter#174 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Giskard-AI/giskard-oss#2840 · 1 comment ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Openarea: repo bug perceived difficulty: 2
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
yeti-platform/yeti#1380 ·