Skip to content

Commit

Permalink
fix: Keep metavar order when making choices_str
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmups committed Oct 3, 2022
1 parent 7feb163 commit 8b9ae77
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/click/types.py
Expand Up @@ -253,9 +253,10 @@ def to_info_dict(self) -> t.Dict[str, t.Any]:

def get_metavar(self, param: "Parameter") -> str:
if param.param_type_name == "option" and not param.show_choices:
choices_str = "|".join(
{convert_type(type(choice)).name.upper() for choice in self.choices}
)
choice_metavars = [
convert_type(type(choice)).name.upper() for choice in self.choices
]
choices_str = "|".join([*dict.fromkeys(choice_metavars)])
else:
choices_str = "|".join([str(i) for i in self.choices])

Expand Down

0 comments on commit 8b9ae77

Please sign in to comment.