pyiron / pyiron/flowrep

Parse in-line if statements

Open
#138 1 comment 0 reactions 1 assignee View on GitHub

@liamhuber is already working on this.

Since Feb 18, 2026.

enhancement
Dominant language
Python
Stars
3
Forks
0
Avg merge
1h 19m
Merged PRs (30d)
5

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.