Use literals as the type for cli opts that take choices
This commit is contained in:
parent
3c1954f329
commit
0eef48b516
@ -409,6 +409,9 @@ def as_type_stub(seq: OptionSpecSeq, disabled: OptionSpecSeq, class_name: str, e
|
|||||||
elif otype == 'list':
|
elif otype == 'list':
|
||||||
t = 'typing.Sequence[str]'
|
t = 'typing.Sequence[str]'
|
||||||
elif otype in ('choice', 'choices'):
|
elif otype in ('choice', 'choices'):
|
||||||
|
if opt['choices']:
|
||||||
|
t = 'typing.Literal[{}]'.format(','.join(f'{x!r}' for x in opt['choices']))
|
||||||
|
else:
|
||||||
t = 'str'
|
t = 'str'
|
||||||
elif otype.startswith('bool-'):
|
elif otype.startswith('bool-'):
|
||||||
t = 'bool'
|
t = 'bool'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user