Repository navigation
Apply show_only_unused to arguments (fixes #125) - #137
Conversation
ClickCompleter(show_only_unused=True) only hid options that were already present on the line; arguments were completed again even after a value had been supplied. _get_completion_for_cmd_args now skips a click.Argument whose value is already bound in the completion context, mirroring the existing option handling. Variadic arguments (nargs=-1) accept further values and are never hidden. Adds regression tests for both the plain and the variadic argument case.
There was a problem hiding this comment.
🟡 Changes recommended
The new argument “already used” detection relies on ctx.params, which can reflect defaults/envvars (not just command-line input) and may incorrectly hide argument completions under show_only_unused=True.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR fixes ClickCompleter(show_only_unused=True) so it also suppresses completions for click.Argument values that have already been provided, matching the existing behavior for click.Option, while keeping variadic arguments (nargs=-1) completable.
Changes:
- Update
_get_completion_for_cmd_argsto skip completing an argument when it is already “used” (except variadic args). - Add regression tests covering both single-value and variadic arguments with
show_only_unused. - Document the behavior change in
Changelog.rst.
File summaries
| File | Description |
|---|---|
click_repl/_completer.py |
Extends show_only_unused behavior to arguments during completion generation. |
tests/test_completion/test_common_tests/test_arg_completion.py |
Adds regression tests for unused-argument hiding and the variadic exception. |
Changelog.rst |
Notes the new show_only_unused behavior for arguments. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The fallback argument detection can incorrectly hide completions for default or environment-derived values.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (1)
click_repl/_completer.py:284
- Fixed-arity multi-value arguments are hidden before all their values have been entered. With
nargs=2, parsingcmd foorecords the source asCOMMANDLINE, but resilient parsing leaves the argument value unbound because the second token is missing; thiscontinuethen suppresses the choices needed for that second value. Hide the argument only after its processed value is actually bound.
if self.show_only_unused and already_present and param.nargs != -1:
continue
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Balanced
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, aligns argument behavior with existing option handling, and includes targeted regression tests plus a changelog entry.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Lite
Fixes #125
ClickCompleter(show_only_unused=True)only hid options that were already present on the line;click.Argumentwas never checked, so an argument kept being completed after a value had been supplied._get_completion_for_cmd_argsnow skips an argument whose value is already bound in the completion context, mirroring the existing option handling; variadic arguments (nargs=-1) accept further values and are never hidden.Regression tests were added to
tests/test_completion/test_common_tests/test_arg_completion.pyfor both the plain and the variadic case; they fail on master and pass with the fix. Full suite: 69 passed, 5 skipped.This change was prepared with AI assistance; the regression test was run locally and fails without the fix.