mirror of
https://github.com/clearml/clearml
synced 2025-03-03 18:52:12 +00:00
Fix argparse with [None] in default parameter (issue #297)
This commit is contained in:
parent
e3109c96d8
commit
4931429054
@ -278,10 +278,11 @@ class _Arguments(object):
|
|||||||
# casting
|
# casting
|
||||||
if v:
|
if v:
|
||||||
if current_action.type:
|
if current_action.type:
|
||||||
v = [current_action.type(a) for a in v]
|
v = [current_action.type(a) if str(a) != str(None) else None for a in v]
|
||||||
elif current_action.default:
|
elif current_action.default:
|
||||||
v_type = type(current_action.default[0])
|
v_type = type(current_action.default[0])
|
||||||
v = [v_type(a) for a in v]
|
if v_type != type(None): # noqa
|
||||||
|
v = [v_type(a) if str(a) != str(None) else None for a in v]
|
||||||
|
|
||||||
if current_action.default is not None or v not in (None, ''):
|
if current_action.default is not None or v not in (None, ''):
|
||||||
arg_parser_arguments[k] = v
|
arg_parser_arguments[k] = v
|
||||||
@ -290,6 +291,7 @@ class _Arguments(object):
|
|||||||
self._task.log.warning(
|
self._task.log.warning(
|
||||||
'Failed parsing task parameter {}="{}" keeping default {}={}'.format(
|
'Failed parsing task parameter {}="{}" keeping default {}={}'.format(
|
||||||
k, v, k, current_action.default))
|
k, v, k, current_action.default))
|
||||||
|
continue
|
||||||
|
|
||||||
elif current_action and not current_action.type:
|
elif current_action and not current_action.type:
|
||||||
# cast manually if there is no type
|
# cast manually if there is no type
|
||||||
|
Loading…
Reference in New Issue
Block a user