Skip to content
Discussion options

You must be logged in to vote

It's deliberate, which took me a minute to believe. Name the flag explicitly and you get both halves of what you want:

fuzzy_muffins: Annotated[
    str,
    typer.Option("--fuzzy-muffins", help="Fuzzy muffins", metavar="FUZZY_MUFFINS"),
] = "Very fuzzy"

0.27 stopped force-lowercasing generated flag names (#1863, it's in the breaking changes list). The rule that bites you lives in get_default_option_flag_name: if your metavar matches the param name case-insensitively once underscores become dashes, the metavar's casing wins the flag. There's a test pinning exactly this, test_parameter_name_casing in tests/test_core.py, where arg9: int = typer.Option(metavar="ARG9") gets invoked as --ARG9.…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@riklopfer
Comment options

Answer selected by riklopfer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
2 participants