Skip to content

Fix shortest-only completion at an empty root prompt - #138

Merged
auvipy merged 1 commit into
click-contrib:masterfrom
Sanjays2402:fix/empty-root-completion
Sep 5, 2026
Merged

auvipy merged 1 commit into
click-contrib:masterfrom
Sanjays2402:fix/empty-root-completion

Conversation

@Sanjays2402

@Sanjays2402 Sanjays2402 commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Guard shortest-only completion when the root prompt has no arguments.
  • Add regression coverage for an empty root prompt.

Testing

  • pytest

@auvipy
auvipy requested review from auvipy and a lite review from Copilot September 5, 2026 07:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is a minimal, correct guard for an empty-list edge case and includes a focused regression test covering the reported failure mode.

Pull request overview

This PR fixes an edge-case bug in ClickCompleter when shortest_only=True and completion is requested at the empty root prompt, preventing an args[-1] access on an empty args list and adding a regression test to lock in the behavior.

Changes:

  • Guard shortest-only option selection against an empty args list in _get_completion_for_cmd_args.
  • Add a regression test ensuring shortest-only completion works at an empty root prompt and produces no stdout output.
File summaries
File Description
click_repl/_completer.py Prevents indexing into an empty args list when applying shortest_only option filtering.
tests/test_completion/test_common_tests/test_option_completion.py Adds regression coverage for completing at an empty root prompt with shortest_only=True.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@auvipy
auvipy merged commit fafbb55 into click-contrib:master Sep 5, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants