Fix type='str' optparse options

This commit is contained in:
Anthony Sottile 2020-04-24 10:43:54 -07:00
parent 2cb1c65c99
commit 3b490bb3c5
2 changed files with 4 additions and 0 deletions

View file

@ -28,6 +28,8 @@ _optparse_callable_map = {
"float": float,
"complex": complex,
"choice": _ARG.NO,
# optparse allows this but does not document it
"str": str,
} # type: Dict[str, Union[Type[Any], _ARG]]

View file

@ -303,6 +303,8 @@ def test_optparse_normalize_callback_option_legacy(optmanager):
('string', 'foo', 'foo'),
('float', '1.5', 1.5),
('complex', '1+5j', 1 + 5j),
# optparse allows this but does not document it
('str', 'foo', 'foo'),
),
)
def test_optparse_normalize_types(optmanager, type_s, input_val, expected):