From 4f61de8e0866376dda0fb57af52f9d7fbdf6048c Mon Sep 17 00:00:00 2001 From: Lucas Gomide Date: Wed, 23 Apr 2025 16:40:44 -0300 Subject: [PATCH] refactor: replace if/raise with assert For this use case `assert` is more appropriate choice --- src/crewai/task.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/crewai/task.py b/src/crewai/task.py index c75a2a9b6..0214ff8da 100644 --- a/src/crewai/task.py +++ b/src/crewai/task.py @@ -488,8 +488,7 @@ class Task(BaseModel): raise e # Re-raise the exception after emitting the event def _process_guardrail(self, task_output: TaskOutput) -> GuardrailResult: - if self._guardrail is None: - raise ValueError("Guardrail is not set") + assert self._guardrail is not None from crewai.utilities.events import ( TaskGuardrailCompletedEvent,