Skip to content

Fix completion stopping after a boolean flag (#142) - #143

Open
jcruizcue wants to merge 1 commit into
click-contrib:masterfrom
jcruizcue:autocompletion-stops-after-boolean-flag
Open

jcruizcue wants to merge 1 commit into
click-contrib:masterfrom
jcruizcue:autocompletion-stops-after-boolean-flag

Conversation

@jcruizcue

@jcruizcue jcruizcue commented Oct 13, 2026 •

Copy link
Copy Markdown

A boolean flag (is_flag=True) consumes no value, so matching it as the last token must not short-circuit completion of the remaining parameters. Previously the completer returned nothing after a flag; now it continues offering the command's other options and arguments while still not offering true/false for the flag itself.

  • _completer.py: skip the param_called/break short-circuit for flags
  • tests: assert completion continues after a flag (options + arguments)
  • Changelog: add entry

Fix #142

A boolean flag (is_flag=True) consumes no value, so matching it as the
last token must not short-circuit completion of the remaining parameters.
Previously the completer returned nothing after a flag; now it continues
offering the command's other options and arguments while still not
offering true/false for the flag itself.

- _completer.py: skip the param_called/break short-circuit for flags
- tests: assert completion continues after a flag (options + arguments)
- Changelog: add entry
@auvipy
auvipy self-requested a review October 14, 2026 03:10
@auvipy

auvipy commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

@charan-rathore would you mind trying and reviewing it?

@charan-rathore

Copy link
Copy Markdown
Contributor

Tried it locally. On master, completing after a boolean flag returns nothing: cmd --verbose <TAB> offers neither the remaining argument choices nor the other options. On this branch both complete, and no true/false value is offered for the flag itself. The new tests cover the short and long flag spellings, the --shout/--no-shout form, and more than one flag in a row; the full suite passes here (72 passed, 5 skipped). Looks good to me.

@auvipy

auvipy commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Looks good to me.

then why the tests are failing in the CI?

@charan-rathore

Copy link
Copy Markdown
Contributor

Checked the failing job: it is the flake8 tox env, not the tests (click81/82/83 all pass). One lint error: tests/test_completion/test_common_tests/test_option_completion.py:59 is 93 chars, over the 90 limit (E501). I reproduce it locally with flake8 click_repl tests. Wrapping that one line should turn CI green; the remaining cancelled jobs were cancelled by the matrix after the failure, not run to a real result.

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.

Autocompletion stops after a boolean flag

3 participants