From ede83be05f047451d56b7d28e2d66eed1c953adc Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Tue, 21 Aug 2018 17:01:20 -0400 Subject: Fixed type hinting for select function --- cmd2/cmd2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd2/cmd2.py') diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 94b75e5f..f516248a 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -2470,7 +2470,7 @@ Usage: Usage: unalias [-a] name [name ...] self._should_quit = True return self._STOP_AND_EXIT - def select(self, opts: Union[str, List[str], List[Tuple[str, Optional[str]]]], prompt: str='Your choice? ') -> str: + def select(self, opts: Union[str, List[str], List[Tuple[Any, Optional[str]]]], prompt: str='Your choice? ') -> str: """Presents a numbered menu to the user. Modelled after the bash shell's SELECT. Returns the item chosen. -- cgit v1.2.1 From fe83dc063216e80c99e4e429494d56e36d4dc055 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Tue, 21 Aug 2018 17:12:49 -0400 Subject: Fixed get_all_commands and get_help_topics to only return function names --- cmd2/cmd2.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'cmd2/cmd2.py') diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index f516248a..f39ee2ee 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -1553,7 +1553,8 @@ class Cmd(cmd.Cmd): def get_all_commands(self) -> List[str]: """Returns a list of all commands.""" - return [cur_name[3:] for cur_name in self.get_names() if cur_name.startswith('do_')] + return [name[3:] for name in self.get_names() + if name.startswith('do_') and isinstance(getattr(self, name), Callable)] def get_visible_commands(self) -> List[str]: """Returns a list of commands that have not been hidden.""" @@ -1568,7 +1569,8 @@ class Cmd(cmd.Cmd): def get_help_topics(self) -> List[str]: """ Returns a list of help topics """ - return [name[5:] for name in self.get_names() if name.startswith('help_')] + return [name[5:] for name in self.get_names() + if name.startswith('help_') and isinstance(getattr(self, name), Callable)] def complete_help(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: """ -- cgit v1.2.1