Skip to content
Discussion options

You must be logged in to vote

This is intentional since 0.27.0. It came in with PR #1863 ("Update metavar printing"), which stopped Typer from lowercasing or uppercasing parameter names. When no option name is given, the flag is built by get_default_option_flag_name in typer/main.py:

def get_default_option_flag_name(name: str, metavar: str | None) -> str:
    flag_name = name.replace("_", "-")
    if metavar is not None:
        meta_flag = metavar.replace("_", "-")
        if meta_flag.lower() == flag_name.lower():
            return meta_flag
    return flag_name

So when the metavar matches the parameter name case-insensitively, the metavar's spelling wins. tests/test_core.py::test_parameter_name_casing tests this d…

Replies: 1 comment 1 reply

Comment options

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

Answer selected by JonKing93
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