Skip to content

Commit

Permalink
Dont access optional subcommand outputs when not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
nx10 committed Jun 14, 2024
1 parent d66798b commit 28bc3a9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/styx/compiler/compile/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,16 @@ def generate_output_building(
resolved_input = f"self.{resolved_input}"

if input_.data.type.is_list:
opt = ""
if input_.data.type.is_optional:
opt = f" if {resolved_input} else None"
func.body.extend(
indent([f"{input_.symbol}=" f"[i.outputs({symbol_execution}) for i in {resolved_input}],"])
indent([f"{input_.symbol}=" f"[i.outputs({symbol_execution}) for i in {resolved_input}]{opt},"])
)
else:
func.body.extend(indent([f"{input_.symbol}={resolved_input}.outputs({symbol_execution}),"]))
o = f"{resolved_input}.outputs({symbol_execution})"
if input_.data.type.is_optional:
o = f"{o} if {resolved_input} else None"
func.body.extend(indent([f"{input_.symbol}={o},"]))

func.body.extend([")"])

0 comments on commit 28bc3a9

Please sign in to comment.