Skip to content

Commit bb27570

Browse files
committed
Ensure expression type converts bools and floats correctly
This should probably be changed to never wrap in quotations
1 parent c52e21b commit bb27570

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

wdlgen/common.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,19 @@ def get_string(self):
2222
return self.get_string_from_type(wd)
2323

2424
def get_string_from_type(self, wdtype):
25+
expression = self.expression
26+
requires_quotes = not (expression is None or isinstance(expression, bool) or isinstance(expression, int) or isinstance(expression, float))
27+
28+
if isinstance(expression, bool):
29+
expression = "true" if expression else "false"
30+
31+
if requires_quotes:
32+
expression = f'"{expression}"'
33+
2534
return self.format.format(
2635
type=wdtype,
2736
name=self.name,
28-
def_w_equals=(" = \"{val}\"".format(val=self.expression) if self.expression else "")
37+
def_w_equals=((" = " + expression) if expression is not None else "")
2938
)
3039

3140

0 commit comments

Comments
 (0)