Skip to content
Myr

shell autocomplete uses normalize_choice() (#3471)

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

authored by David Lord · committed by GitHub · parents bee3314, 32ae2ac · Browse files · 3 files+5 added−3 removed
This commit

State

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

Diff stats

3 files+5 added−3 removed

  • tests:+2 added−1 removed
  • other:+3 added−2 removed

3 files+5 added−3 removed

modified:src/click/types.py+1 added-2 removed
406 unmodified lines
407 .. versionadded:: 8.0408 """409 from click.shell_completion import CompletionItem410411 str_choices = map(str, self.choices)412411 str_choices = [self.normalize_choice(choice, ctx) for choice in self.choices]412 if self.case_sensitive:413 matched = (c for c in str_choices if c.startswith(incomplete))414 else:415 incomplete = incomplete.lower()
883 unmodified lines
modified:tests/test_shell_completion.py+2 added-1 removed
471 unmodified lines
472 )473 assert result.output == "plain,a\nplain,b\n"474475476# case_sensitive=False normalizes values to lowercase, matching remains case insensitive476@pytest.mark.parametrize(("value", "expect"), [(False, ["Au", "al"]), (True, ["al"])])477@pytest.mark.parametrize(("value", "expect"), [(False, ["au", "al"]), (True, ["al"])])478def test_choice_case_sensitive(value, expect):479 cli = Command(480 "cli",481 params=[Option(["-a"], type=Choice(["Au", "al", "Bc"], case_sensitive=value))],
144 unmodified lines
modified:CHANGES.rst+2 added
4 unmodified lines
56Unreleased78- Zsh completion scripts parse correctly on Windows. :issue:`3277`9- Shell completion of `Choice` `Enum` values produces a valid completion10 result. :issue:`3015`111213Version 8.4.014-------------
1463 unmodified lines