refactor: replace if/raise with assert

For this use case `assert` is more appropriate choice
This commit is contained in:
Lucas Gomide
2025-04-23 16:40:44 -03:00
parent 098a9ba519
commit 4f61de8e08

View File

@@ -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,