Skip to content

[rejected AI] Case-insensitive Choice completion misses Unicode case-folding matches #3879

Closed as not planned

Description

@januththedev

Description

Choice uses casefold() for case-insensitive conversion, but shell_complete() lowercases the incomplete value and compares it with lower(). This makes completion fail for Unicode case-folding expansions.

For example, Choice(["ẞ"], case_sensitive=False) accepts "ß" during conversion because both values case-fold to "ss", but completion for the incomplete value "ß" returns no suggestion because "ss".lower().startswith("ß") is false.

Steps to reproduce

from click import Choice

choice = Choice(["ẞ"], case_sensitive=False)
assert choice.convert("ß", None, None) == "ẞ"

# A completion callback using this Choice receives incomplete="ß".
# It currently produces no completion item, even though the normalized choice is "ss".

The relevant implementation is Choice.shell_complete() in src/click/types.py; it uses lower() while normalize_choice() uses casefold().

Expected behavior

Case-insensitive shell completion should use the same Unicode-aware normalization as conversion and return the normalized "ss" suggestion for incomplete "ß".

Actual behavior

No completion item is returned.

Environment

  • Latest main at the time of filing
  • Python 3.12+
  • Click shell completion

I searched existing issues and pull requests for Unicode casefolding and Choice completion and did not find a matching report. A regression test covering ẞ/ß would prevent this from recurring.

Activity

  1. januththedev commented on Sep 24, 2026

    @januththedev
    Author

    I prepared and pushed a focused fix on januththedev:fix/unicode-casefold-completion:

    GitHub rejected PR creation for this account with does not have the correct permissions to execute CreatePullRequest, apparently due Click's first-time-contributor controls. Could a maintainer approve this contribution or open the equivalent PR from the branch when possible?

  2. ThiefMaster commented on Sep 24, 2026

    @ThiefMaster
    Member

    Now why would you create this PR via the API and not via the GH web interface? Because you are using some AI agent by any chance?

    Read our AI policy: https://palletsprojects.com/contributing/llm-ai

  3. added
    rejected AIContribution rejected because of its untrustworthy AI origin
    on Sep 24, 2026
  4. changed the title [-]Case-insensitive Choice completion misses Unicode case-folding matches[/-] [+][rejected AI] Case-insensitive Choice completion misses Unicode case-folding matches[/+] on Sep 24, 2026
  5. locked as resolved and limited conversation to collaborators on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    rejected AIContribution rejected because of its untrustworthy AI origin

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions