setting expose_value=false for an argument causes crash when auto-completing.
To replicate:
# example.py
import click
@click.command
@click.argument('a', expose_value=False)
def main():
pass
main()
$ _EXAMPLE_PY_COMPLETE=zsh_complete COMP_CWORD=1 COMP_WORDS="BUG " python example.py BUG
you should get something like the following
File "/home/amir/projects/click/bug", line 13, in <module>
gogo()
File "/home/amir/projects/click/src/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/home/amir/projects/click/src/click/core.py", line 1050, in main
self._main_shell_completion(extra, prog_name, complete_var)
File "/home/amir/projects/click/src/click/core.py", line 1125, in _main_shell_completion
rv = shell_complete(self, ctx_args, prog_name, complete_var, instruction)
File "/home/amir/projects/click/src/click/shell_completion.py", line 49, in shell_complete
echo(comp.complete())
File "/home/amir/projects/click/src/click/shell_completion.py", line 291, in complete
completions = self.get_completions(args, incomplete)
File "/home/amir/projects/click/src/click/shell_completion.py", line 272, in get_completions
obj, incomplete = _resolve_incomplete(ctx, args, incomplete)
File "/home/amir/projects/click/src/click/shell_completion.py", line 575, in _resolve_incomplete
if _is_incomplete_argument(ctx, param):
File "/home/amir/projects/click/src/click/shell_completion.py", line 439, in _is_incomplete_argument
value = ctx.params[param.name]
KeyError: 'a'
I think the correct behavior is that nothing should happen or some thing should be printed to stdout. but it shouldn't crash
Environment:
- Python version: 3.10
- Click version: main
setting
expose_value=falsefor an argument causes crash when auto-completing.To replicate:
you should get something like the following
I think the correct behavior is that nothing should happen or some thing should be printed to stdout. but it shouldn't crash
Environment: