Skip to content
Myr

use generator when returning completions

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Nicholas Wiles · committed by Nicholas Wiles · parent b0621f0 · Browse files · 2 files+8 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+8 added−6 removed

  • tests:+2 added−1 removed
  • other:+6 added−5 removed

2 files+8 added−6 removed

modified:click/_bashcomplete.py+6 added-5 removed
104 unmodified lines
105 :return: all the possible user-specified completions for the param106 """107 choices = []108 if isinstance(cmd_param.type, Choice):109 choices.extend(cmd_param.type.choices)109 choices = cmd_param.type.choices110 elif cmd_param.autocompletion is not None:111 choices.extend(cmd_param.autocompletion(ctx=ctx,112 args=args,113 incomplete=incomplete))114 return choices111 choices = cmd_param.autocompletion(ctx=ctx,112 args=args,113 incomplete=incomplete)114 for c in choices:115 yield c116117def get_choices(cli, prog_name, args, incomplete):118 """119 :param cli: command definition
75 unmodified lines
modified:tests/test_bashcomplete.py+2 added-1 removed
83 unmodified lines
84 pass8586 COLORS = ['red', 'green', 'blue']87 def get_colors(ctx, args, incomplete):88 return COLORS88 for c in COLORS:89 yield c9091 CSUB_OPT_CHOICES = ['foo', 'bar']92 CSUB_CHOICES = ['bar', 'baz']93 @bsub.command('csub')
150 unmodified lines