Skip to content

Case handling for Choice help output (values forced to lowercase) #588

Closed

Description

@Romazes

Expected Behavior

Values passed to click.Choice should preserve their original casing when displayed in --help output.

Example:

--brokerage [Interactive Brokers|Tradier|Oanda|Bitfinex|Coinbase Advanced Trade|Binance|Zerodha|Samco|Terminal Link|Trading Technologies|Kraken|CharlesSchwab|IQFeed|Polygon|CoinApi|ThetaData|Custom data only|Bybit|TradeStation|Alpaca|Tastytrade|Eze]

Actual Behavior

Since Click 8.2.0, all values are displayed in lowercase, regardless of how they were registered:

--brokerage [paper trading|interactive brokers|tradier|oanda|bitfinex|coinbase advanced trade|binance|zerodha|samco|terminal link|trading technologies|kraken|charlesschwab|bybit|tradestation|alpaca|tastytrade|eze]

This misleads users into thinking only lowercase values are accepted.

Potential Solution

  • create custom class MyChoice(Choice)
    • override get_metavar(...)
  • Continue using case-folding for parsing input when case_sensitive=False.
  • The regression likely comes from PR #2796, which lowercases values when registering.

Reproducing the Problem

  • run: lean live deploy --help

  • Click 8.1.8: casing preserved ✅

  • Click 8.2.0+: values all lowercase ❌

System Information

  • Click version(s): 8.2.0, 8.2.1 (regression)
  • Last working version: 8.1.8
  • OS: All (confirmed on Windows 10, Ubuntu 22.04)
  • Python: 3.11

Checklist

  • I have completely filled out this template
  • I have confirmed that this issue exists on the current master branch
  • I have confirmed that this is not a duplicate issue by searching issues
  • I have provided detailed steps to reproduce the issue

Activity

  1. Amadeus-22 commented on Sep 29, 2026

    @Amadeus-22
    Contributor

    The --help casing was fixed in #641, but the invalid-choice error still lists lowercased values (e.g. 'bogus' is not one of 'equity', 'forex', ... for lean data generate --security-type bogus), since Click 8.2 builds that message from the casefolded choices too. I have a small follow-up that overrides get_invalid_choice_message in CaseInsensitiveChoice, with tests for Click 8.1 and 8.5. Happy to open a PR if that's useful.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions