From 0eef48b516e7009296710427519711ae05764a15 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 24 Apr 2020 15:28:04 +0530 Subject: [PATCH] Use literals as the type for cli opts that take choices --- kitty/cli.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kitty/cli.py b/kitty/cli.py index 41ddeae1b..d0fd273a2 100644 --- a/kitty/cli.py +++ b/kitty/cli.py @@ -409,7 +409,10 @@ def as_type_stub(seq: OptionSpecSeq, disabled: OptionSpecSeq, class_name: str, e elif otype == 'list': t = 'typing.Sequence[str]' elif otype in ('choice', 'choices'): - t = 'str' + if opt['choices']: + t = 'typing.Literal[{}]'.format(','.join(f'{x!r}' for x in opt['choices'])) + else: + t = 'str' elif otype.startswith('bool-'): t = 'bool' else: