Unwanted newlines being added to output.
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia con il riproduttore Python fornito e segui come tomlkit serializza le tabelle dopo l'aggiunta di tabelle annidate. Confronta gli output round-trip e modificato, quindi aggiungi un test di regressione che copra il comportamento delle newline; il lavoro è completo quando la spaziatura delle tabelle segue la struttura costruita esplicitamente senza newline aggiuntive inattese.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I want to group my tables:
[first]
foo = 5
bar = 20
[first.a.b.c]
alice = 10
bob = 30
[second]
foo = 3
bar = 21
[second.a.b.c]
alice = 15
bob = 3543
When I try to manually construct this, I instead get
[first]
foo = 5
bar = 20
[first.a.b.c]
alice = 10
bob = 30
[second]
foo = 3
bar = 21
[second.a.b.c]
alice = 15
bob = 3543
I expected no newlines to be added for me and explicitly called out a newline between [first.a.b.c] table and [second]. Newlines being added surprised me and made made me wonder if tomlkit was properly preserving the lack of newlines but it seems to.
So I created the following test case to experiment with how newlines are dealt with
import tomlkit
t = tomlkit.loads("""[first]
foo = 5
bar = 20
[first.a.b.c]
alice = 10
bob = 30
[second]
foo = 3
bar = 21
[second.a.b.c]
alice = 15
bob = 3543""")
print("Round-trip")
print("```toml")
print(tomlkit.dumps(t))
print("```")
print()
t["second"].add("extra", tomlkit.table())
t["second"].add("extra1", tomlkit.table())
three = tomlkit.table()
three["foo"] = 2
three["bar"] = 1
child = tomlkit.table()
child["alice"] = 3
child["bob"] = 10
three["child"] = child
t["three"] = three
print("Changed")
print("```toml")
print(tomlkit.dumps(t))
print("```")
print()
The output is:
Round-trip
[first]
foo = 5
bar = 20
[first.a.b.c]
alice = 10
bob = 30
[second]
foo = 3
bar = 21
[second.a.b.c]
alice = 15
bob = 3543
Changed
[first]
foo = 5
bar = 20
[first.a.b.c]
alice = 10
bob = 30
[second]
foo = 3
bar = 21
[second.a.b.c]
alice = 15
bob = 3543
[second.extra]
[second.extra1]
[three]
foo = 2
bar = 1
[three.child]
alice = 3
bob = 10
I was surprised that second.extra didn't have a newline before it but second.extra1 did. I imagine this just shows how the newlines are being auto-added but it is still surprising.
- 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 confirmed issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
open-webui/open-webui#30750 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100