Skip to content

Commit

Permalink
fix issue of none assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle committed Aug 29, 2024
1 parent 57ffb73 commit 6f80e5a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions antarest/core/tasks/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,22 +158,23 @@ class TaskJob(Base): # type: ignore
study: "Study" = relationship("Study", back_populates="jobs", uselist=False)

def to_dto(self, with_logs: bool = False) -> TaskDTO:
assert self.result_status is not None
assert self.result_msg is not None
result = None
if self.completion_date:
assert self.result_status is not None
assert self.result_msg is not None
result = TaskResult(
success=self.result_status,
message=self.result_msg,
return_value=self.result,
)
return TaskDTO(
id=self.id,
owner=self.owner_id,
creation_date_utc=str(self.creation_date),
completion_date_utc=str(self.completion_date) if self.completion_date else None,
name=self.name,
status=TaskStatus(self.status),
result=TaskResult(
success=self.result_status,
message=self.result_msg,
return_value=self.result,
)
if self.completion_date
else None,
result=result,
logs=sorted([log.to_dto() for log in self.logs], key=lambda log: log.id) if with_logs else None,
type=self.type,
ref_id=self.ref_id,
Expand Down

0 comments on commit 6f80e5a

Please sign in to comment.