Skip to content

shell autocomplete uses normalize_choice() #3471

Merged
davidism merged 1 commit into
pallets:stablefrom
panyamkeerthana:stable
May 19, 2026
Merged

shell autocomplete uses normalize_choice() #3471
davidism merged 1 commit into
pallets:stablefrom
panyamkeerthana:stable

Conversation

@panyamkeerthana
Copy link
Copy Markdown
Contributor

Shell completion for Choice with enum types doesn't work. When using Choice(MyEnum), autocomplete suggests "MyEnum.foo" instead of "foo", which is the actual accepted value. (#3015) I've changed shell_complete() to use normalize_choice() instead of simply converting choices to strings like in #3017, this does fail the test_choice_case_sensitive() test though.

I can fix the enum autocomplete bug, but there's a decision to make:

A) Manually handle enums, preserve original case

  • test_choice_case_sensitive passes as is
  • Autocomplete doesn't respect normalize_choice() overrides

B) Use normalize_choice() for consistency (current approach)

  • Requires updating test: ["Au", "al"] to ["au", "al"] when case_sensitive=False
  • Autocomplete is con sistent with other text behavior

I can amend the current approach to update the test I've just left a note for now! 😃

@panyamkeerthana panyamkeerthana force-pushed the stable branch 2 times, most recently from a831c49 to 105a044 Compare May 18, 2026 21:54
@davidism davidism added this to the 8.4.1 milestone May 18, 2026
@davidism davidism changed the title fix: shell autocomplete using normalize_choice() shell autocomplete uses normalize_choice() May 18, 2026
-fixes enum choice autocomplete showing "MyEnum.foo" instead of "foo"
-changed shell_complete() to use normalize_choice() instead of simply converting choices to strings
@davidism davidism merged commit 3c12ce7 into pallets:stable May 19, 2026
12 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.

2 participants