Skip to content
Open
1 change: 1 addition & 0 deletions doc/changelog.d/5047.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Raise instead of BaseTask.get_id implicitly returning None
14 changes: 13 additions & 1 deletion src/ansys/fluent/core/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ def __init__(self, task_name):
super().__init__(f"Could not create command instance for task {task_name}.")


class TaskLookupError(LookupError):
"""Raised when a task cannot be found by it's ID"""

def __init__(self, task_name):
"""Initialise TaskLookupError."""
super().__init__(
f"Task ID not found for task '{task_name}'. "
"This may indicate the task was not properly initialized."
)


def camel_to_snake_case(camel_case_str: str) -> str:
"""Convert camel case input string to snake case output string."""
try:
Expand Down Expand Up @@ -326,7 +337,7 @@ def inactive_tasks(self) -> list:
"""
return []

def get_id(self) -> str:
def get_id(self) -> str: # pylint: disable=missing-raises-doc
"""Get the unique string identifier of this task, as it is in the application.

Returns
Expand All @@ -341,6 +352,7 @@ def get_id(self) -> str:
type_, id_ = k.split(":")
if type_ == "TaskObject":
return id_
raise TaskLookupError(self.name())

def get_idx(self) -> int:
"""Get the unique integer index of this task, as it is in the application.
Expand Down