diff --git a/docs_src/multiple_values/arguments_with_multiple_values/tutorial003.py b/docs_src/multiple_values/arguments_with_multiple_values/tutorial003.py index f752bdef87..bbfd575643 100644 --- a/docs_src/multiple_values/arguments_with_multiple_values/tutorial003.py +++ b/docs_src/multiple_values/arguments_with_multiple_values/tutorial003.py @@ -14,6 +14,7 @@ def main( names: Tuple[str, str, str, SuperHero] = typer.Argument( ("Harry", "Hermione", "Ron", "hero3"), enum_by_name=True, + case_sensitive=False, help="Select 4 characters to play with", ), ): diff --git a/docs_src/multiple_values/arguments_with_multiple_values/tutorial003_an.py b/docs_src/multiple_values/arguments_with_multiple_values/tutorial003_an.py index ac07a64b3d..662b9d7fa2 100644 --- a/docs_src/multiple_values/arguments_with_multiple_values/tutorial003_an.py +++ b/docs_src/multiple_values/arguments_with_multiple_values/tutorial003_an.py @@ -14,7 +14,7 @@ class SuperHero(str, Enum): def main( names: Annotated[ Tuple[str, str, str, SuperHero], - typer.Argument(enum_by_name=True, help="Select 4 characters to play with"), + typer.Argument(enum_by_name=True, help="Select 4 characters to play with", case_sensitive=False), ] = ("Harry", "Hermione", "Ron", "hero3"), ): for name in names: diff --git a/tests/test_tutorial/test_multiple_values/test_arguments_with_multiple_values/test_tutorial003_an.py b/tests/test_tutorial/test_multiple_values/test_arguments_with_multiple_values/test_tutorial003_an.py index 814133dec4..6e5f8c2d09 100644 --- a/tests/test_tutorial/test_multiple_values/test_arguments_with_multiple_values/test_tutorial003_an.py +++ b/tests/test_tutorial/test_multiple_values/test_arguments_with_multiple_values/test_tutorial003_an.py @@ -37,7 +37,7 @@ def test_invalid_args(): def test_valid_args(): - result = runner.invoke(app, ["Draco", "Hagrid", "Dobby", "hero1"]) + result = runner.invoke(app, ["Draco", "Hagrid", "Dobby", "HERO1"]) assert result.exit_code == 0 assert "Hello Draco" in result.stdout assert "Hello Hagrid" in result.stdout diff --git a/typer/main.py b/typer/main.py index f50ca9eb13..462f6d65bf 100644 --- a/typer/main.py +++ b/typer/main.py @@ -650,13 +650,13 @@ def convertor(value: Any) -> Any: def generate_enum_name_convertor(enum: Type[Enum]) -> Callable[..., Any]: - lower_name_map = {str(item.name).lower(): item for item in enum} + val_map = {str(item.name): item for item in enum} def convertor(value: Any) -> Any: if value is not None: - low = str(value).lower() - if low in lower_name_map: - return lower_name_map[low] + val = str(value) + if val in val_map: + return val_map[val] return convertor