Skip to content

Commit

Permalink
chore: more type aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Jul 18, 2022
1 parent 85afee8 commit 407870f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/app_model/registries/_menus_reg.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Callable,
Dict,
Final,
Iterable,
Iterator,
List,
Optional,
Expand All @@ -28,7 +29,7 @@ class MenusRegistry:
menus_changed = Signal(set)

def __init__(self) -> None:
self._menu_items: Dict[str, List[MenuOrSubmenu]] = {}
self._menu_items: Dict[MenuId, List[MenuOrSubmenu]] = {}

def append_menu_items(
self, items: Sequence[Tuple[MenuId, MenuOrSubmenu]]
Expand Down Expand Up @@ -73,13 +74,13 @@ def _dispose() -> None:

def __iter__(
self,
) -> Iterator[Tuple[str, List[MenuOrSubmenu]]]:
) -> Iterator[Tuple[MenuId, Iterable[MenuOrSubmenu]]]:
yield from self._menu_items.items()

def __contains__(self, id: object) -> bool:
return id in self._menu_items

def get_menu(self, menu_id: str) -> List[MenuOrSubmenu]:
def get_menu(self, menu_id: MenuId) -> List[MenuOrSubmenu]:
"""Return menu items for `menu_id`."""
# using method rather than __getitem__ so that subclasses can use arguments
return self._menu_items[menu_id]
Expand Down Expand Up @@ -117,7 +118,7 @@ def _render(self) -> List[str]:
lines.append("")
return lines

def iter_menu_groups(self, menu_id: str) -> Iterator[List[MenuOrSubmenu]]:
def iter_menu_groups(self, menu_id: MenuId) -> Iterator[List[MenuOrSubmenu]]:
"""Iterate over menu groups for `menu_id`.
Groups are broken into sections (lists of menu or submenu items) based on
Expand Down

0 comments on commit 407870f

Please sign in to comment.