diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-07-09 23:18:28 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-07-09 23:18:28 -0400 |
commit | 766f8f7b02f771d7cd4ca812c1f0ebfe76e5faf8 (patch) | |
tree | a37ba6637c53adf45dbf0f7f4a345997f7a269cd /cmd2/cmd2.py | |
parent | 60c18dfcc371713cebb22cc47aec173bd95687ce (diff) | |
download | cmd2-git-766f8f7b02f771d7cd4ca812c1f0ebfe76e5faf8.tar.gz |
Fixed a couple type hints and minor pep8-style formatting issues
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r-- | cmd2/cmd2.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 524d1d8e..8bdcf083 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -1756,7 +1756,7 @@ class Cmd(cmd.Cmd): finally: return self._run_cmdfinalization_hooks(stop, statement) - def _run_cmdfinalization_hooks(self, stop: bool, statement: Statement) -> bool: + def _run_cmdfinalization_hooks(self, stop: bool, statement: Optional[Statement]) -> bool: """Run the command finalization hooks""" try: data = plugin.CommandFinalizationData(stop, statement) @@ -3179,7 +3179,7 @@ Script should contain one command per line, just like command would be typed in cls._validate_callable_param_count(func, 0) # make sure there is no return notation signature = inspect.signature(func) - if signature.return_annotation != None: + if signature.return_annotation is not None: raise TypeError("{} must declare return a return type of 'None'".format( func.__name__, )) @@ -3259,20 +3259,18 @@ Script should contain one command per line, just like command would be typed in signature = inspect.signature(func) _, param = list(signature.parameters.items())[0] if param.annotation != plugin.CommandFinalizationData: - raise TypeError("{} must have one parameter declared with type 'cmd2.plugin.CommandFinalizationData'".format( - func.__name__ - )) + raise TypeError("{} must have one parameter declared with type " + "'cmd2.plugin.CommandFinalizationData'".format(func.__name__)) if signature.return_annotation != plugin.CommandFinalizationData: - raise TypeError("{} must declare return a return type of 'cmd2.plugin.CommandFinalizationData'".format( - func.__name__ - )) - pass + raise TypeError("{} must declare return a return type of " + "'cmd2.plugin.CommandFinalizationData'".format(func.__name__)) def register_cmdfinalization_hook(self, func: Callable): """Register a hook to be called after a command is completed, whether it completes successfully or not.""" self._validate_cmdfinalization_callable(func) self._cmdfinalization_hooks.append(func) + class History(list): """ A list of HistoryItems that knows how to respond to user requests. """ |