File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 49
49
# Passing lists or dicts with argparse is not straight forward, so we use pass them as
50
50
# string and parse them with `ast.literal_eval`
51
51
# ref: https://stackoverflow.com/questions/7625786/type-dict-in-argparse-add-argument
52
+ # We follow a similar approach with bools
53
+ # ref: https://stackoverflow.com/a/59579733/18471590
54
+ # ref: https://stackoverflow.com/questions/715417/converting-from-a-string-to-boolean-in-python/18472142#18472142
55
+
56
+ def str2bool (v ):
57
+ return v .lower () in ("yes" , "true" , "t" , "1" )
58
+
59
+
52
60
FIELD_TYPE_CONVERTERS = {
53
- fields .Bool : bool ,
54
- fields .Boolean : bool ,
61
+ fields .Bool : str2bool ,
62
+ fields .Boolean : str2bool ,
55
63
fields .Date : str ,
56
64
fields .DateTime : str ,
57
65
fields .Dict : ast .literal_eval ,
@@ -111,6 +119,8 @@ def _fields_to_dict(fields_in):
111
119
val_help += '\n Type: list, enclosed as string: "[...]"'
112
120
elif val_type is fields .Dict :
113
121
val_help += '\n Type: dict, enclosed as string: "{...}"'
122
+ elif val_type in [fields .Bool , fields .Boolean ]:
123
+ val_help += '\n Type: bool'
114
124
else :
115
125
val_help += f"\n Type: { param ['type' ].__name__ } "
116
126
if val_type is fields .Field :
You can’t perform that action at this time.
0 commit comments