From 59379e88da62e25e5f8a13f630867de3a03c35cd Mon Sep 17 00:00:00 2001 From: Mathias Millet Date: Fri, 7 Aug 2020 10:09:07 +0200 Subject: [PATCH] use value.name as input value for enums --- .coveragerc | 8 -------- typer/main.py | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 18cdff1942..0000000000 --- a/.coveragerc +++ /dev/null @@ -1,8 +0,0 @@ -[run] - -source = - typer - tests - docs_src - -parallel = True diff --git a/typer/main.py b/typer/main.py index 5ff9774440..663e54780b 100644 --- a/typer/main.py +++ b/typer/main.py @@ -451,7 +451,7 @@ def param_path_convertor(value: Optional[str] = None) -> Optional[Path]: def generate_enum_convertor(enum: Type[Enum]) -> Callable: - lower_val_map = {str(val.value).lower(): val for val in enum} + lower_val_map = {str(val.name).lower(): val for val in enum} def convertor(value: Any) -> Any: if value is not None: @@ -581,7 +581,7 @@ def get_click_type( ) elif lenient_issubclass(annotation, Enum): return click.Choice( - [item.value for item in annotation], + [item.name for item in annotation], case_sensitive=parameter_info.case_sensitive, ) raise RuntimeError(f"Type not yet supported: {annotation}") # pragma no cover