pipenv's Trivia patch to make tomlkit dump toml's inline table
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start by comparing tomlkit/container.py and tomlkit/items.py with the referenced pipenv vendor patch, focusing on Trivia, Comment, and InlineTableDict handling. Review the existing test coverage for dumping inline tables, then verify the finished behavior against the patch without changing unrelated vendored code.
Written by the indexing model from the issue text.
Description
pipenv applies a patch to their vendored copy of tomlkit, and it seems that it doesnt exist here yet.
The patch is https://github.com/pypa/pipenv/blob/master/tasks/vendoring/patches/vendor/tomlkit-fix.patch
Parts of that have been merged, but the bit that looks missing is:
diff -ru tomlkit-0.5.3-orig/tomlkit/container.py tomlkit-0.5.3/tomlkit/container.py
--- tomlkit-0.5.3-orig/tomlkit/container.py 2018-11-14 23:10:40.697032200 +0700
+++ tomlkit-0.5.3/tomlkit/container.py 2019-03-14 10:57:20.658602016 +0700
@@ -19,6 +19,7 @@
from .items import Key
from .items import Null
from .items import Table
+from .items import Trivia
from .items import Whitespace
from .items import item as _item
@@ -223,7 +224,12 @@
for i in idx:
self._body[i] = (None, Null())
else:
- self._body[idx] = (None, Null())
+ old_data = self._body[idx][1]
+ trivia = getattr(old_data, "trivia", None)
+ if trivia and trivia.comment:
+ self._body[idx] = (None, Comment(Trivia(comment_ws="", comment=trivia.comment)))
+ else:
+ self._body[idx] = (None, Null())
super(Container, self).__delitem__(key.key)
diff -ru tomlkit-0.5.3-orig/tomlkit/items.py tomlkit-0.5.3/tomlkit/items.py
--- tomlkit-0.5.3-orig/tomlkit/items.py 2018-11-20 01:11:57.965421000 +0700
+++ tomlkit-0.5.3/tomlkit/items.py 2019-03-14 10:59:38.451740952 +0700
@@ -20,6 +20,7 @@
from ._compat import long
from ._compat import unicode
from ._utils import escape_string
+from toml.decoder import InlineTableDict
if PY2:
from functools32 import lru_cache
@@ -40,7 +41,10 @@
elif isinstance(value, float):
return Float(value, Trivia(), str(value))
elif isinstance(value, dict):
- val = Table(Container(), Trivia(), False)
+ if isinstance(value, InlineTableDict):
+ val = InlineTable(Container(), Trivia())
+ else:
+ val = Table(Container(), Trivia(), False)
for k, v in sorted(value.items(), key=lambda i: (isinstance(i[1], dict), i[0])):
val[k] = item(v, _parent=val)
Is this an appropriate addition to tomlkit?
It appears the author was @frostming , originally at https://github.com/pypa/pipenv/commits/6df7d8861da841e552049dcde9ff9a0f23edc01e/tasks/vendoring/patches/vendor/tomlkit-dump-inline-table.patch
I dont see any similar patch in https://github.com/sdispater/tomlkit/commits?author=frostming
Ideally they should be submit the patch, or someone elses should submit it with the patch author set to the correct author. Ping also @techalchemy who has been heavily involved in the pipenv vendoring.
- Dominant language
- Python
- Stars
- 850
- Forks
- 163
- Avg merge
- 13m
- Merged PRs (30d)
- 2
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python-poetry/tomlkit
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
python-poetry/tomlkit#546 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
python-poetry/tomlkit#603 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
python-poetry/tomlkit#580 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
python-poetry/tomlkit#577 ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
python-poetry/tomlkit#574 · 5 comments ·
All issues in python-poetry/tomlkit
Similar issues
-
bug confirmed issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-webui/open-webui#30750 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 90/100