Use metavar to list the choices for a CLI arg when custom values are also accepted (#21760)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Harry Mellor
2025-07-28 20:31:10 +01:00
committed by GitHub
parent 7d44c691b0
commit 94b71ae106
3 changed files with 20 additions and 7 deletions

View File

@@ -72,6 +72,10 @@ def test_get_type(type_hints, type, expected):
"type": int,
"choices": [1, 2]
}),
({str, Literal["x", "y"]}, {
"type": str,
"metavar": ["x", "y"]
}),
({Literal[1, "a"]}, Exception),
])
def test_literal_to_kwargs(type_hints, expected):