Skip to content
Merged
12 changes: 3 additions & 9 deletions src/a2a/utils/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,10 @@
raise ValueError('TextPart content cannot be empty')

context_id_str = request.context_id
if context_id_str is not None:
try:
uuid.UUID(context_id_str)
context_id = context_id_str
except (ValueError, AttributeError, TypeError) as e:
raise ValueError(
f"Invalid context_id: '{context_id_str}' is not a valid UUID."
) from e
else:
if not context_id_str:
context_id = str(uuid.uuid4())
else:
context_id = context_id_str

Check failure on line 35 in src/a2a/utils/task.py

View workflow job for this annotation

GitHub Actions / Lint Code Base

Ruff (SIM108)

src/a2a/utils/task.py:32:5: SIM108 Use ternary operator `context_id = str(uuid.uuid4()) if not context_id_str else context_id_str` instead of `if`-`else`-block

return Task(
status=TaskStatus(state=TaskState.submitted),
Expand Down
Loading