Skip to content

Commit 2a3b2d1

Browse files
authored
Add types to the append() methods of the Table and InlineTable classes (#282)
* Add types to the append() methods of the Table and InlineTable classes * Add None to key type and fix SIM910 errorswar
1 parent 3f48f7e commit 2a3b2d1

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

tomlkit/container.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ def item(self, key: Union[Key, str]) -> Item:
477477
if not isinstance(key, Key):
478478
key = SingleKey(key)
479479

480-
idx = self._map.get(key, None)
480+
idx = self._map.get(key)
481481
if idx is None:
482482
raise NonExistentKey(key)
483483

@@ -645,7 +645,7 @@ def __getitem__(self, key: Union[Key, str]) -> Union[Item, "Container"]:
645645
if not isinstance(key, Key):
646646
key = SingleKey(key)
647647

648-
idx = self._map.get(key, None)
648+
idx = self._map.get(key)
649649
if idx is None:
650650
raise NonExistentKey(key)
651651

@@ -681,7 +681,7 @@ def _replace(
681681
if not isinstance(key, Key):
682682
key = SingleKey(key)
683683

684-
idx = self._map.get(key, None)
684+
idx = self._map.get(key)
685685
if idx is None:
686686
raise NonExistentKey(key)
687687

tomlkit/items.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,7 @@ def __copy__(self) -> "Table":
15741574
self.display_name,
15751575
)
15761576

1577-
def append(self, key, _item):
1577+
def append(self, key: Union[Key, str, None], _item: Any) -> "Table":
15781578
"""
15791579
Appends a (key, item) to the table.
15801580
"""
@@ -1605,7 +1605,7 @@ def append(self, key, _item):
16051605

16061606
return self
16071607

1608-
def raw_append(self, key: Union[Key, str], _item: Any) -> "Table":
1608+
def raw_append(self, key: Union[Key, str, None], _item: Any) -> "Table":
16091609
"""Similar to :meth:`append` but does not copy indentation."""
16101610
if not isinstance(_item, Item):
16111611
_item = item(_item)
@@ -1691,7 +1691,7 @@ def __init__(
16911691
def discriminant(self) -> int:
16921692
return 10
16931693

1694-
def append(self, key, _item):
1694+
def append(self, key: Union[Key, str, None], _item: Any) -> "InlineTable":
16951695
"""
16961696
Appends a (key, item) to the table.
16971697
"""

0 commit comments

Comments
 (0)