Skip to content

Commit

Permalink
fix: items.Array __init__ didn't ignore Null that _group_values (pyth…
Browse files Browse the repository at this point in the history
  • Loading branch information
laixintao committed Aug 10, 2022
1 parent 6375a2f commit 57763b3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions tests/test_items.py
@@ -1,5 +1,6 @@
import math
import pickle
import copy

from datetime import date
from datetime import datetime
Expand Down Expand Up @@ -860,3 +861,17 @@ def test_table_copy():
table["foo"] = "baz"
assert table_copy["foo"] == "bar"
assert table_copy.as_string() == 'foo = "bar"\n'


def test_copy_copy():
result = parse("""
[tool.poetry]
classifiers = [
# comment
"a",
"b",
]
""")
classifiers = result["tool"]["poetry"]["classifiers"]
new = copy.copy(classifiers)
assert new == classifiers
4 changes: 2 additions & 2 deletions tomlkit/items.py
Expand Up @@ -656,7 +656,6 @@ def as_string(self) -> str:
return self._raw

def __add__(self, other):

return self._new(int(self._raw) + other)

def __radd__(self, other):
Expand Down Expand Up @@ -1139,7 +1138,8 @@ def __init__(
) -> None:
super().__init__(trivia)
list.__init__(
self, [v.value for v in value if not isinstance(v, (Whitespace, Comment))]
self,
[v.value for v in value if not isinstance(v, (Whitespace, Comment, Null))],
)
self._index_map: Dict[int, int] = {}
self._value = self._group_values(value)
Expand Down

0 comments on commit 57763b3

Please sign in to comment.