0.27 Option flag getting clobbered #1900
-
First Check
Example Code# /// script
# requires-python = ">=3.14"
# dependencies = ["typer==0.27"]
# ///
from typing import Annotated
import typer
def main( fuzzy_muffins: Annotated[
str,
typer.Option(
help="Fuzzy muffins",
show_default=True,
metavar="FUZZY_MUFFINS",
),
] = "Very fuzzy") -> None:
print(f"Hello {fuzzy_muffins}")
if __name__ == "__main__":
typer.run(main)Description
expected note the capitalization on the flag Operating SystemmacOS Operating System DetailsNo response Project Version0.27 Python VersionPython 3.14.5 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
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 One thing to watch: this is a parse change, not just help cosmetics. On 0.27 |
Beta Was this translation helpful? Give feedback.
It's deliberate, which took me a minute to believe. Name the flag explicitly and you get both halves of what you want:
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_casingintests/test_core.py, wherearg9: int = typer.Option(metavar="ARG9")gets invoked as--ARG9.…