Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/test_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ def test_array_behaves_like_a_list():
content = """a = [1, 2,] # Comment
"""
doc = parse(content)
assert str(doc) == "{'a': [1, 2]}"
assert str(doc["a"]) == "[1, 2]"

assert doc["a"] == [1, 2]
Expand Down
9 changes: 9 additions & 0 deletions tomlkit/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,12 @@ def as_string(self) -> str:
def __str__(self) -> str:
return f"{self._trivia.indent}{decode(self._trivia.comment)}"

def unwrap(self):
return decode(self._trivia.comment).lstrip("#").lstrip()

def __repr__(self) -> str:
return f"<{self.__class__.__name__} {self.unwrap()!r}>"


class Integer(Item, _CustomInt):
"""
Expand Down Expand Up @@ -1965,3 +1971,6 @@ def as_string(self) -> str:

def _getstate(self, protocol=3) -> tuple:
return ()

def __repr__(self):
return "<Null>"
Loading