-
-
Notifications
You must be signed in to change notification settings - Fork 111
Closed
Description
Minimal example for reproduction:
def test_no_whitespace():
content = dedent("""\
[a.b.c.d]
[unrelated]
[a.b.e]
""")
doc = loads(content)
doc['a']
assert dumps(doc) == contentThe value of dumps(doc) is:
[a.b.c.d]
[unrelated]
[a.b.e]The newline is added in tomlkit/container.py:187, when the [a.b.e] block is merged in with the [a.b.c.d] block. Setting the parsed flag in the container prior to the items being merged in seems to be a minimally invasive way to fix it, but I don't understand the nuance here to know if it's a good solution. I.e.
Lines 249 to 259 in 6351f3d
| # Create a new element to replace the old one | |
| current = copy.deepcopy(current) | |
| for k, v in item.value.body: | |
| current.append(k, v) | |
| self._body[ | |
| ( | |
| current_idx[-1] | |
| if isinstance(current_idx, tuple) | |
| else current_idx | |
| ) | |
| ] = (current_body_element[0], current) |
current = copy.deepcopy(current)
current.value.parsing(True)
for k, v in item.value.body:
current.append(k, v)
...If this is an acceptable fix I'm happy to make a PR with the test and change, otherwise I'm happy to fix it in a different way or defer to someone with more knowledge of the library's inner workings haha.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels