Skip to content

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

@Romazes

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions