Comment not parsed when value is boolean
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Inizia con la riproduzione di tomlkit.loads e segui come vengono creati i valori sotto d["foo"], confrontando il percorso booleano con i percorsi degli interi e delle stringhe. Il lavoro è completato quando un valore booleano espone il proprio commento finale tramite trivia.comment, in accordo con il comportamento esistente e la riproduzione fornita.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Python
- Stelle
- 850
- Fork
- 163
- Merge medio
- 13m
- PR unite (30g)
- 2
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di python-poetry/tomlkit
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
python-poetry/tomlkit#546 · 2 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
python-poetry/tomlkit#603 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
python-poetry/tomlkit#580 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
python-poetry/tomlkit#577 ·
-
Looking for a co-maintainer Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
python-poetry/tomlkit#574 · 5 commenti ·
Tutte le issue di python-poetry/tomlkit
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
xinnan-tech/xiaozhi-fde-talk#263 ·
-
rules
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
huggingface/Repo2RLEnv#163 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
huggingface/sentence-transformers#4074 ·
-
comp/dashboard invalid P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
NousResearch/hermes-agent#121143 ·