Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

unwrap raises KeyAlreadyPresent for an out-of-order AoT element extension

オープン
#577 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
python
領域
tooling

調査の方向性

まず、issue に記載されている tomlkit.parse()、doc["y"]、doc.unwrap()、および OutOfOrderTableProxy のマージパスを追跡します。提供されたドキュメントを再現し、y へのアクセスとアンラップで KeyAlreadyPresent が発生しなくなっていることを検証するとともに、doc.as_string() が引き続き入力と完全に一致することを確認します。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
Python
スター
850
フォーク
163
平均マージ
13分
マージ済み PR(30日)
2

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

python-poetry/tomlkit のほかの issue

python-poetry/tomlkit の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。