diff --git a/pkgs/clan-cli/clan_cli/api/serde.py b/pkgs/clan-cli/clan_cli/api/serde.py index 394f077e2..84328186b 100644 --- a/pkgs/clan-cli/clan_cli/api/serde.py +++ b/pkgs/clan-cli/clan_cli/api/serde.py @@ -230,10 +230,18 @@ def construct_value( raise ClanError(msg, location=f"{loc}") return field_value + # Enums if origin is Enum: if field_value not in origin.__members__: msg = f"Expected one of {', '.join(origin.__members__)}, got {field_value}" raise ClanError(msg, location=f"{loc}") + return origin.__members__[field_value] # type: ignore + + if isinstance(t, type) and issubclass(t, Enum): + if field_value not in t.__members__: + msg = f"Expected one of {', '.join(t.__members__)}, got {field_value}" + raise ClanError(msg, location=f"{loc}") + return t.__members__[field_value] # type: ignore if origin is Annotated: (base_type,) = get_args(t)