Use literals as the type for cli opts that take choices
This commit is contained in:
parent
3c1954f329
commit
0eef48b516
@ -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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user