diff --git a/CHANGES.rst b/CHANGES.rst index 354300967..0af01f647 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,8 @@ Version 8.4.1 Unreleased - Zsh completion scripts parse correctly on Windows. :issue:`3277` +- Shell completion of `Choice` `Enum` values produces a valid completion + result. :issue:`3015` Version 8.4.0 diff --git a/src/click/types.py b/src/click/types.py index 556f20f2b..1ca3e9b5d 100644 --- a/src/click/types.py +++ b/src/click/types.py @@ -408,8 +408,7 @@ def shell_complete( """ from click.shell_completion import CompletionItem - str_choices = map(str, self.choices) - + str_choices = [self.normalize_choice(choice, ctx) for choice in self.choices] if self.case_sensitive: matched = (c for c in str_choices if c.startswith(incomplete)) else: diff --git a/tests/test_shell_completion.py b/tests/test_shell_completion.py index 23c5ff05c..6d9a58305 100644 --- a/tests/test_shell_completion.py +++ b/tests/test_shell_completion.py @@ -473,7 +473,8 @@ def complete(ctx, param, incomplete): assert result.output == "plain,a\nplain,b\n" -@pytest.mark.parametrize(("value", "expect"), [(False, ["Au", "al"]), (True, ["al"])]) +# case_sensitive=False normalizes values to lowercase, matching remains case insensitive +@pytest.mark.parametrize(("value", "expect"), [(False, ["au", "al"]), (True, ["al"])]) def test_choice_case_sensitive(value, expect): cli = Command( "cli",