Skip to content

Commit c498531

Browse files
authored
Merge pull request #195 from sdispater:remove-is-tomlkit
Remove the is_tomlkit check
2 parents deac74d + a46ac20 commit c498531

File tree

4 files changed

+8
-34
lines changed

4 files changed

+8
-34
lines changed

tests/test_items.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,10 @@
1010

1111
from tomlkit import api
1212
from tomlkit import parse
13-
from tomlkit.check import is_tomlkit
1413
from tomlkit.exceptions import NonExistentKey
15-
from tomlkit.items import AoT
1614
from tomlkit.items import Array
1715
from tomlkit.items import Bool
1816
from tomlkit.items import Comment
19-
from tomlkit.items import Date
20-
from tomlkit.items import DateTime
21-
from tomlkit.items import Float
2217
from tomlkit.items import InlineTable
2318
from tomlkit.items import Integer
2419
from tomlkit.items import Item
@@ -28,7 +23,6 @@
2823
from tomlkit.items import String
2924
from tomlkit.items import StringType
3025
from tomlkit.items import Table
31-
from tomlkit.items import Time
3226
from tomlkit.items import Trivia
3327
from tomlkit.items import item
3428
from tomlkit.parser import Parser
@@ -124,7 +118,6 @@ def test_null_unwrap():
124118

125119
def test_aot_unwrap():
126120
d = item([{"a": "A"}, {"b": "B"}])
127-
assert is_tomlkit(d)
128121
unwrapped = d.unwrap()
129122
assert_is_ppo(unwrapped, list)
130123
for du, dw in zip(unwrapped, d):
@@ -161,7 +154,6 @@ def test_array_unwrap():
161154
def test_abstract_table_unwrap():
162155
table = item({"foo": "bar"})
163156
super_table = item({"table": table, "baz": "borg"})
164-
assert is_tomlkit(super_table["table"])
165157

166158
table_unwrapped = super_table.unwrap()
167159
sub_table = table_unwrapped["table"]

tomlkit/check.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

tomlkit/container.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from ._compat import decode
1212
from ._utils import merge_dicts
13-
from .check import is_tomlkit
1413
from .exceptions import KeyAlreadyPresent
1514
from .exceptions import NonExistentKey
1615
from .exceptions import TOMLKitError
@@ -53,7 +52,7 @@ def unwrap(self) -> str:
5352
if k is None:
5453
continue
5554

56-
if not isinstance(k, str):
55+
if isinstance(k, Key):
5756
k = k.key
5857

5958
if isinstance(v, Item):

tomlkit/items.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from ._compat import decode
2828
from ._utils import CONTROL_CHARS
2929
from ._utils import escape_string
30-
from .check import is_tomlkit
3130
from .exceptions import InvalidStringError
3231
from .toml_char import TOMLChar
3332

@@ -1091,7 +1090,7 @@ def __init__(self, value: list, trivia: Trivia, multiline: bool = False) -> None
10911090
def unwrap(self) -> str:
10921091
unwrapped = []
10931092
for v in self:
1094-
if is_tomlkit(v):
1093+
if isinstance(v, Item):
10951094
unwrapped.append(v.unwrap())
10961095
else:
10971096
unwrapped.append(v)
@@ -1343,16 +1342,12 @@ def __init__(self, value: "container.Container", trivia: Trivia):
13431342

13441343
def unwrap(self):
13451344
unwrapped = {}
1346-
for k in self:
1347-
if is_tomlkit(k):
1348-
nk = k.unwrap()
1349-
else:
1350-
nk = k
1351-
if is_tomlkit(self[k]):
1352-
nv = self[k].unwrap()
1353-
else:
1354-
nv = self[k]
1355-
unwrapped[nk] = nv
1345+
for k, v in self.items():
1346+
if isinstance(k, Key):
1347+
k = k.key
1348+
if isinstance(v, Item):
1349+
v = v.unwrap()
1350+
unwrapped[k] = v
13561351

13571352
return unwrapped
13581353

0 commit comments

Comments
 (0)