Skip to content

Commit

Permalink
Move the None check around
Browse files Browse the repository at this point in the history
Signed-off-by: liamhuber <[email protected]>
  • Loading branch information
liamhuber committed Jan 17, 2025
1 parent ca36572 commit 9488d69
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pyiron_workflow/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ def _after_node_setup(

@property
def inputs_map(self) -> bidict | None:
self._deduplicate_nones(self._inputs_map)
if self._inputs_map is not None:
self._deduplicate_nones(self._inputs_map)
return self._inputs_map

@inputs_map.setter
Expand All @@ -271,25 +272,26 @@ def inputs_map(self, new_map: dict | bidict | None):

@property
def outputs_map(self) -> bidict | None:
self._deduplicate_nones(self._outputs_map)
if self._outputs_map is not None:
self._deduplicate_nones(self._outputs_map)
return self._outputs_map

@outputs_map.setter
def outputs_map(self, new_map: dict | bidict | None):
self._outputs_map = self._sanitize_map(new_map)

def _sanitize_map(self, new_map: dict | bidict | None) -> bidict | None:
self._deduplicate_nones(new_map)
if new_map is not None:
if isinstance(new_map, dict):
self._deduplicate_nones(new_map)
new_map = bidict(new_map)
return new_map

@staticmethod
def _deduplicate_nones(some_map: dict | bidict | None):
if some_map is not None:
for k, v in some_map.items():
if v is None:
some_map[k] = (None, f"{k} disabled")
def _deduplicate_nones(some_map: dict | bidict):
for k, v in some_map.items():
if v is None:
some_map[k] = (None, f"{k} disabled")

@property
def inputs(self) -> Inputs:
Expand Down

0 comments on commit 9488d69

Please sign in to comment.