@@ -667,7 +667,7 @@ def _complete_for_arg(self, action: argparse.Action,
667667
668668 if callable (arg_choices [0 ]):
669669 completer = arg_choices [0 ]
670- elif isinstance ( arg_choices [ 0 ], str ) and callable ( getattr ( self . _cmd2_app , arg_choices [ 0 ])) :
670+ else :
671671 completer = getattr (self ._cmd2_app , arg_choices [0 ])
672672
673673 # extract the positional and keyword arguments from the tuple
@@ -701,32 +701,17 @@ def _resolve_choices_for_arg(self, action: argparse.Action, used_values=()) -> L
701701 # is the argument a string? If so, see if we can find an attribute in the
702702 # application matching the string.
703703 if isinstance (args , str ):
704- try :
705- args = getattr (self ._cmd2_app , args )
706- except AttributeError :
707- # Couldn't find anything matching the name
708- return []
704+ args = getattr (self ._cmd2_app , args )
709705
710706 # is the provided argument a callable. If so, call it
711707 if callable (args ):
712708 try :
713- try :
714- args = args (self ._cmd2_app )
715- except TypeError :
716- args = args ()
709+ args = args (self ._cmd2_app )
717710 except TypeError :
718- return []
719-
720- try :
721- iter (args )
722- except TypeError :
723- pass
724- else :
725- # filter out arguments we already used
726- args = [arg for arg in args if arg not in used_values ]
711+ args = args ()
727712
728- if len ( args ) > 0 :
729- return args
713+ # filter out arguments we already used
714+ return [ arg for arg in args if arg not in used_values ]
730715
731716 return []
732717
0 commit comments