Skip to content

Commit

Permalink
add types
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Oct 10, 2024
1 parent bf25db7 commit e3332b4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
5 changes: 3 additions & 2 deletions spinn_utilities/ranged/abstract_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def __init__(self, range_dict: RangeDictionary[T]):
"""
self._range_dict = range_dict

def __getitem__(self, key: Union[int, slice, Iterable[int]]):
def __getitem__(self, key: Union[int, slice, Iterable[int]]
) -> AbstractView[T]:
"""
Support for the view[x] based the type of the key
Expand All @@ -64,7 +65,7 @@ def __getitem__(self, key: Union[int, slice, Iterable[int]]):
return self._range_dict.view_factory(ids[key])
return self._range_dict.view_factory([ids[i] for i in key])

def __setitem__(self, key: str, value: T):
def __setitem__(self, key: str, value: T) -> None:
"""
See :py:meth:`AbstractDict.set_value`
Expand Down
5 changes: 3 additions & 2 deletions spinn_utilities/ranged/ids_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def set_value(
for _id in self._ids:
ranged_list.set_value_by_id(the_id=_id, value=value)

def set_value_by_ids(self, key: str, ids: Iterable[int], value: T):
def set_value_by_ids(self, key: str, ids: Iterable[int], value: T) -> None:
"""
Sets a already existing key to the new value. For the view specified.
Expand All @@ -84,7 +84,8 @@ def set_value_by_ids(self, key: str, ids: Iterable[int], value: T):
rl.set_value_by_id(the_id=_id, value=value)

@overload
def iter_all_values(self, key: str, update_safe=False) -> Iterator[T]:
def iter_all_values(
self, key: str, update_safe: bool = False) -> Iterator[T]:
...

@overload
Expand Down
7 changes: 4 additions & 3 deletions spinn_utilities/ranged/single_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ def get_value(self, key: _Keys) -> Union[T, Dict[str, T]]:
for k in key}

@overload
def iter_all_values(self, key: str, update_safe=False) -> Iterator[T]:
def iter_all_values(self, key: str, update_safe: bool = False
) -> Iterator[T]:
...

@overload
def iter_all_values(
self, key: Optional[_StrSeq], update_safe=False) -> Iterator[
Dict[str, T]]:
self, key: Optional[_StrSeq], update_safe: bool = False
) -> Iterator[Dict[str, T]]:
...

@overrides(AbstractDict.iter_all_values)
Expand Down
4 changes: 2 additions & 2 deletions spinn_utilities/ranged/slice_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ def update_safe_iter_all_values(self, key: str) -> Iterator[T]:

@overload
def iter_all_values(
self, key: str, update_safe=False) -> Iterator[T]:
self, key: str, update_safe: bool = False) -> Iterator[T]:
...

@overload
def iter_all_values(
self, key: Optional[_StrSeq] = None,
update_safe=False) -> Iterator[Dict[str, T]]:
update_safe: bool = False) -> Iterator[Dict[str, T]]:
...

@overrides(AbstractDict.iter_all_values, extend_defaults=True)
Expand Down

0 comments on commit e3332b4

Please sign in to comment.