diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-06-10 16:19:39 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-06-10 16:19:39 -0400 |
commit | 2565ae7832edfe42ee7631473f67a09b6789e679 (patch) | |
tree | 20764f73508c206d3df9dfcf66bc2cdb1e47af1d /cmd2/cmd2.py | |
parent | 6ba8d96321bf4052105f6f7fb6027d9e7073ea6c (diff) | |
download | cmd2-git-2565ae7832edfe42ee7631473f67a09b6789e679.tar.gz |
Added .mypy_cache to .gitignore
Also:
- Added a few more type hints
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r-- | cmd2/cmd2.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 4b6185dd..3d2a8afe 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -39,7 +39,7 @@ import platform import re import shlex import sys -from typing import Any, Callable, Dict, List, Optional, Tuple, Union +from typing import Any, Callable, Dict, List, Mapping, Optional, Tuple, Union import pyperclip @@ -940,7 +940,7 @@ class Cmd(cmd.Cmd): return completions_matches def index_based_complete(self, text: str, line: str, begidx: int, endidx: int, - index_dict: Dict[int, Union[Iterable, Callable]], + index_dict: Mapping[int, Union[Iterable, Callable]], all_else: Union[None, Iterable, Callable] = None) -> List[str]: """ Tab completes based on a fixed position in the input string @@ -1950,7 +1950,8 @@ class Cmd(cmd.Cmd): """ funcname = self._func_named(statement.command) if not funcname: - return self.default(statement) + self.default(statement) + return # Since we have a valid command store it in the history if statement.command not in self.exclude_from_history: @@ -1959,7 +1960,8 @@ class Cmd(cmd.Cmd): try: func = getattr(self, funcname) except AttributeError: - return self.default(statement) + self.default(statement) + return stop = func(statement) return stop @@ -2420,8 +2422,8 @@ Usage: Usage: unalias [-a] name [name ...] readline.remove_history_item(hlen - 1) try: - response = int(response) - result = fulloptions[response - 1][0] + choice = int(response) + result = fulloptions[choice - 1][0] break except (ValueError, IndexError): self.poutput("{!r} isn't a valid choice. Pick a number between 1 and {}:\n".format(response, |