@@ -173,11 +173,17 @@ def cat_decorator(func):
173173 return cat_decorator
174174
175175
176- def with_argument_list (func : Callable , preserve_quotes : bool = False ) -> Callable :
177- """A decorator to alter the arguments passed to a do_* cmd2
178- method. Default passes a string of whatever the user typed.
179- With this decorator, the decorated method will receive a list
180- of arguments parsed from user input using shlex.split()."""
176+ def with_argument_list (func : Callable [[Statement ], Optional [bool ]],
177+ preserve_quotes : bool = False ) -> Callable [[List ], Optional [bool ]]:
178+ """A decorator to alter the arguments passed to a do_* cmd2 method. Default passes a string of whatever the user
179+ typed. With this decorator, the decorated method will receive a list of arguments parsed from user input using
180+ shlex.split().
181+
182+ :param func: do_* method this decorator is wrapping
183+ :param preserve_quotes: if True, then arguments passed to arparse maintain their quotes
184+ :return: function that gets passed a list of argument strings
185+ """
186+ """"""
181187 import functools
182188
183189 @functools .wraps (func )
@@ -189,18 +195,19 @@ def cmd_wrapper(self, cmdline):
189195 return cmd_wrapper
190196
191197
192- def with_argparser_and_unknown_args (argparser : argparse .ArgumentParser , preserve_quotes : bool = False ) -> Callable :
198+ def with_argparser_and_unknown_args (argparser : argparse .ArgumentParser , preserve_quotes : bool = False ) -> \
199+ Callable [[argparse .Namespace , List ], Optional [bool ]]:
193200 """A decorator to alter a cmd2 method to populate its ``args`` argument by parsing arguments with the given
194201 instance of argparse.ArgumentParser, but also returning unknown args as a list.
195202
196203 :param argparser: unique instance of ArgumentParser
197- :param preserve_quotes: if True, then the arguments passed to arparse be maintain their quotes
198- :return: function that gets passed parsed args and a list of unknown args
204+ :param preserve_quotes: if True, then arguments passed to arparse maintain their quotes
205+ :return: function that gets passed argparse- parsed args and a list of unknown argument strings
199206 """
200207 import functools
201208
202209 # noinspection PyProtectedMember
203- def arg_decorator (func : Callable ):
210+ def arg_decorator (func : Callable [[ Statement ], Optional [ bool ]] ):
204211 @functools .wraps (func )
205212 def cmd_wrapper (instance , cmdline ):
206213 lexed_arglist = parse_quoted_string (cmdline , preserve_quotes )
@@ -230,18 +237,19 @@ def cmd_wrapper(instance, cmdline):
230237 return arg_decorator
231238
232239
233- def with_argparser (argparser : argparse .ArgumentParser , preserve_quotes : bool = False ) -> Callable :
240+ def with_argparser (argparser : argparse .ArgumentParser ,
241+ preserve_quotes : bool = False ) -> Callable [[argparse .Namespace ], Optional [bool ]]:
234242 """A decorator to alter a cmd2 method to populate its ``args`` argument by parsing arguments
235243 with the given instance of argparse.ArgumentParser.
236244
237245 :param argparser: unique instance of ArgumentParser
238- :param preserve_quotes: if True, then the arguments passed to arparse be maintain their quotes
239- :return: function that gets passed parsed args
246+ :param preserve_quotes: if True, then arguments passed to arparse maintain their quotes
247+ :return: function that gets passed the argparse- parsed args
240248 """
241249 import functools
242250
243251 # noinspection PyProtectedMember
244- def arg_decorator (func : Callable ):
252+ def arg_decorator (func : Callable [[ Statement ], Optional [ bool ]] ):
245253 @functools .wraps (func )
246254 def cmd_wrapper (instance , cmdline ):
247255 lexed_arglist = parse_quoted_string (cmdline , preserve_quotes )
0 commit comments