Skip to content

Commit

Permalink
fix type hinting
Browse files Browse the repository at this point in the history
  • Loading branch information
tlakshmi authored and tlakshmi committed Nov 21, 2024
1 parent deb11a2 commit 6b237e5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pyironflow/create_macro.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ def get_input_types_from_hint(node_input: dict):
new_type = ""

for listed_type in list(type_hint_to_tuple(node_input.type_hint)):
if listed_type == None:
listed_type = type(None)
if listed_type.__name__ != "NoneType":
new_type = new_type + listed_type.__name__ + "|"

new_type = new_type[:-1]

for listed_type in list(type_hint_to_tuple(node_input.type_hint)):
if listed_type == None:
listed_type = type(None)
if listed_type.__name__ == "NoneType":
new_type = "Optional[" + new_type + "]"
if new_type != "":
new_type = ": Optional[" + new_type + "]"

return new_type

Expand All @@ -49,8 +54,7 @@ def custom(wf = dict, name = str, root_path='../pyiron_nodes/pyiron_nodes'):
value = "'" + j.value + "'"
else:
value = str(j.value)
var_def = var_def + v.label + "_" + j.label + ": " + get_input_types_from_hint(j)+ " = " + value + ", "
print(var_def)
var_def = var_def + v.label + "_" + j.label + get_input_types_from_hint(j)+ " = " + value + ", "

var_def = var_def[:-2]

Expand Down

0 comments on commit 6b237e5

Please sign in to comment.