Comment not parsed when value is boolean
まだ誰も着手していません。
評価
調査の方向性
tomlkit.loads の再現から始め、d["foo"] 配下の値がどのように作成されるかを追跡し、boolean のパスを integer および string のパスと比較します。boolean 値が trivia.comment を通じて末尾のコメントを公開し、既存の動作および提供された再現と一致すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
I've just tried to set up comment parsing in a TOML config file to see if I could use it for documentation, and it seems like it'll work except for when the configured value is a boolean.
When I drop into a debugger and look at the attributes of the parsed value:
(Pdb) p default_toml[section]
{'CONVERT_TO_PDF': False}
(Pdb) x = default_toml[section]
(Pdb) y = x["CONVERT_TO_PDF"]
and then tab complete to show the attributes, the dict x has a trivia attribute but the value y does not:
(Pdb) p y.
y.__abs__ y.__floor__ y.__invert__ y.__radd__ y.__rpow__ y.__trunc__
y.__add__ y.__floordiv__ y.__le__ y.__rand__ y.__rrshift__ y.__xor__
y.__and__ y.__format__ y.__lshift__ y.__rdivmod__ y.__rshift__ y.as_integer_ratio
y.__bool__ y.__ge__ y.__lt__ y.__reduce__ y.__rsub__ y.bit_length
y.__ceil__ y.__getattribute__ y.__mod__ y.__reduce_ex__ y.__rtruediv__ y.conjugate
y.__class__ y.__getnewargs__ y.__mul__ y.__repr__ y.__rxor__ y.denominator
y.__delattr__ y.__gt__ y.__ne__ y.__rfloordiv__ y.__setattr__ y.from_bytes
y.__dir__ y.__hash__ y.__neg__ y.__rlshift__ y.__sizeof__ y.imag
y.__divmod__ y.__index__ y.__new__ y.__rmod__ y.__str__ y.numerator
y.__doc__ y.__init__ y.__or__ y.__rmul__ y.__sub__ y.real
y.__eq__ y.__init_subclass__ y.__pos__ y.__ror__ y.__subclasshook__ y.to_bytes
y.__float__ y.__int__ y.__pow__ y.__round__ y.__truediv__
- I checked in
x.trivia.commentbut there's nothing there - For other types of value (integer, float and string) comments are expected to be in the
trivia.commentattribute
Is this a bug, or should I be looking for the comment in another place?
To minimally reproduce:
import tomlkit
d = tomlkit.loads("""
[foo]
bar = 1 # hello
baz = false # goodbye
""")
v1 = d["foo"]["bar"]
v2 = d["foo"]["baz"]
print(hasattr(v1, "trivia"))
print(getattr(v1.trivia, "comment"))
print(hasattr(v2, "trivia"))
⇣
True
# hello
False
- 主要言語
- Python
- スター
- 850
- フォーク
- 163
- 平均マージ
- 13分
- マージ済み PR(30日)
- 2
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python-poetry/tomlkit のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
python-poetry/tomlkit#546 · コメント 2 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
python-poetry/tomlkit#603 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
python-poetry/tomlkit#580 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
python-poetry/tomlkit#577 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
python-poetry/tomlkit#574 · コメント 5 件 ·
python-poetry/tomlkit の issue をすべて見る
似ている issue
-
bug confirmed issue
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
open-webui/open-webui#30750 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 90/100