Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to tomlkit for parsing and writing #3191

Closed
wants to merge 16 commits into from
3 changes: 1 addition & 2 deletions pipenv/vendor/tomlkit/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ def remove(self, key): # type: (Union[Key, str]) -> Container
self._body[idx] = (None, Comment(Trivia(comment_ws="", comment=trivia.comment)))
else:
self._body[idx] = (None, Null())
super(Container, self).__delitem__(key.key)

super(Container, self).__delitem__(key.key)
uranusjr marked this conversation as resolved.
Show resolved Hide resolved

return self

Expand Down
11 changes: 5 additions & 6 deletions tasks/vendoring/patches/vendor/tomlkit-update-items.patch
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@ index 37014921..5ddd72e7 100644
+from .items import Trivia
from .items import Whitespace
from .items import item as _item

@@ -189,9 +190,14 @@ class Container(dict):
if idx is None:
raise NonExistentKey(key)

- self._body[idx] = (None, Null())
+ old_data = self._body[idx][1]
+ trivia = getattr(old_data, "trivia", None)
+ if trivia and getattr(trivia, "comment", None):
+ self._body[idx] = (None, Comment(Trivia(comment_ws="", comment=trivia.comment)))
+ else:
+ self._body[idx] = (None, Null())
+ super(Container, self).__delitem__(key.key)
+ super(Container, self).__delitem__(key.key)

- super(Container, self).__delitem__(key.key)

return self