diff options
Diffstat (limited to 'cmd2/argparse_completer.py')
| -rw-r--r-- | cmd2/argparse_completer.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/cmd2/argparse_completer.py b/cmd2/argparse_completer.py index 21007289..ef35eabc 100644 --- a/cmd2/argparse_completer.py +++ b/cmd2/argparse_completer.py @@ -641,8 +641,11 @@ class ArgparseCompleter: arg_choices.sort() self._cmd2_app.matches_sorted = True - # Since choices can be various types, convert them all to strings - arg_choices = [str(x) for x in arg_choices] + # Since choices can be various types, make sure they are all strings + for index, choice in enumerate(arg_choices): + # Prevent converting anything that is already a str (i.e. CompletionItem) + if not isinstance(choice, str): + arg_choices[index] = str(choice) else: arg_choices = getattr(arg_state.action, ATTR_CHOICES_CALLABLE, None) if arg_choices is None: |
