Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotate some extra returns #548

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pyiron_workflow/mixin/semantics.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,25 +316,25 @@ def add_child(
child.parent = self
return child

def _ensure_child_has_no_other_parent(self, child: Semantic):
def _ensure_child_has_no_other_parent(self, child: Semantic) -> None:
if child.parent is not None and child.parent is not self:
raise ValueError(
f"The child ({child.label}) already belongs to the parent "
f"{child.parent.label}. Please remove it there before trying to "
f"add it to this parent ({self.label})."
)

def _this_child_is_already_at_this_label(self, child: Semantic, label: str):
def _this_child_is_already_at_this_label(self, child: Semantic, label: str) -> bool:
return (
label == child.label
and label in self.child_labels
and self.children[label] is child
)

def _this_child_is_already_at_a_different_label(self, child, label):
def _this_child_is_already_at_a_different_label(self, child, label) -> bool:
return child.parent is self and label != child.label

def _get_unique_label(self, label: str, strict_naming: bool):
def _get_unique_label(self, label: str, strict_naming: bool) -> str:
if label in self.__dir__():
if label in self.child_labels:
if strict_naming:
Expand All @@ -351,7 +351,7 @@ def _get_unique_label(self, label: str, strict_naming: bool):
)
return label

def _add_suffix_to_label(self, label):
def _add_suffix_to_label(self, label: str) -> str:
i = 0
new_label = label
while new_label in self.__dir__():
Expand Down Expand Up @@ -416,7 +416,7 @@ def __setstate__(self, state):
child.parent = self


def _ensure_path_is_not_cyclic(parent, child: Semantic):
def _ensure_path_is_not_cyclic(parent, child: Semantic) -> None:
if isinstance(parent, Semantic) and parent.semantic_path.startswith(
child.semantic_path + child.semantic_delimiter
):
Expand Down
Loading