Skip to content

Commit

Permalink
Add types to the append() methods of the Table and InlineTable
Browse files Browse the repository at this point in the history
…classes (#282)

* Add types to the append() methods of the Table and InlineTable classes

* Add None to key type and fix SIM910 errorswar
  • Loading branch information
joaopalmeiro authored Apr 27, 2023
1 parent 3f48f7e commit 2a3b2d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions tomlkit/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ def item(self, key: Union[Key, str]) -> Item:
if not isinstance(key, Key):
key = SingleKey(key)

idx = self._map.get(key, None)
idx = self._map.get(key)
if idx is None:
raise NonExistentKey(key)

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

idx = self._map.get(key, None)
idx = self._map.get(key)
if idx is None:
raise NonExistentKey(key)

Expand Down Expand Up @@ -681,7 +681,7 @@ def _replace(
if not isinstance(key, Key):
key = SingleKey(key)

idx = self._map.get(key, None)
idx = self._map.get(key)
if idx is None:
raise NonExistentKey(key)

Expand Down
6 changes: 3 additions & 3 deletions tomlkit/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,7 @@ def __copy__(self) -> "Table":
self.display_name,
)

def append(self, key, _item):
def append(self, key: Union[Key, str, None], _item: Any) -> "Table":
"""
Appends a (key, item) to the table.
"""
Expand Down Expand Up @@ -1605,7 +1605,7 @@ def append(self, key, _item):

return self

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

def append(self, key, _item):
def append(self, key: Union[Key, str, None], _item: Any) -> "InlineTable":
"""
Appends a (key, item) to the table.
"""
Expand Down

0 comments on commit 2a3b2d1

Please # to comment.