When we encounter a typical if-...-else statement, we find anast.If:
def simple_if_else(x, y):
if my_cond(x, y): # noqa: SIM108
z = my_add(x, y)
else:
z = my_mul(x, y)
return z
It would be nice to extend WorkflowParser.handle_assignment to also handle ast.IfExp so we can parse an else-node out of the equivalent python:
def simple_if_else(x, y):
z = my_add(x, y) if my_cond(x, y) else my_mul(x, y)
return z
I think such an extension should be quite straightforward. My current understanding is that if we have an assignment available (z above) then it's always possible to reformulate the weaker ast.IfExp back into the more powerful ast.If.
I want to focus on getting the core functionality up for all the control flow parsers before adding sugar to a given flow, so this can wait.
When we encounter a typical if-...-else statement, we find an
ast.If:It would be nice to extend
WorkflowParser.handle_assignmentto also handleast.IfExpso we can parse an else-node out of the equivalent python:I think such an extension should be quite straightforward. My current understanding is that if we have an assignment available (
zabove) then it's always possible to reformulate the weakerast.IfExpback into the more powerfulast.If.I want to focus on getting the core functionality up for all the control flow parsers before adding sugar to a given flow, so this can wait.