Skip to content

Commit

Permalink
Jump through mypy hoops
Browse files Browse the repository at this point in the history
It doesn't recognize the __set__ for fset methods on the property, so my usual routes for super'ing the setter are failing. This is annoying, but I don't see it being particularly harmful as the method is private.

Signed-off-by: liamhuber <[email protected]>
  • Loading branch information
liamhuber committed Jan 11, 2025
1 parent 8dc1bcb commit 2d24d3d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pyiron_workflow/mixin/semantics.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ def parent(self) -> SemanticParent | None:

@parent.setter
def parent(self, new_parent: SemanticParent | None) -> None:
self._set_parent(new_parent)

def _set_parent(self, new_parent: SemanticParent | None):
"""
mypy is uncooperative with super calls for setters, so we pull the behaviour
out.
"""
if new_parent is self._parent:
# Exit early if nothing is changing
return
Expand Down Expand Up @@ -365,7 +372,7 @@ def parent(self) -> SemanticParent | None:
@parent.setter
def parent(self, new_parent: SemanticParent | None) -> None:
self._ensure_path_is_not_cyclic(new_parent, self)
super(SemanticParent, type(self)).parent.__set__(self, new_parent)
self._set_parent(new_parent)

def __getstate__(self):
state = super().__getstate__()
Expand Down

0 comments on commit 2d24d3d

Please sign in to comment.