Skip to content

Commit eae5ac7

Browse files
committed
fix linting
1 parent 00c3312 commit eae5ac7

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

src/a2a/utils/task.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,15 @@ def new_task(request: Message) -> Task:
2929
raise ValueError('TextPart content cannot be empty')
3030

3131
context_id_str = request.context_id
32-
context_id = request.context_id
33-
if context_id is not None:
32+
if context_id_str is not None:
3433
try:
35-
# Validate that the provided context_id is a valid UUID.
36-
uuid.UUID(context_id)
37-
except ValueError:
38-
# Re-raise as ValueError with a more specific message.
34+
uuid.UUID(context_id_str)
35+
context_id = context_id_str
36+
except (ValueError, AttributeError, TypeError) as e:
3937
raise ValueError(
40-
f"Invalid context_id: '{context_id}' is not a valid UUID."
41-
) from None
38+
f"Invalid context_id: '{context_id_str}' is not a valid UUID."
39+
) from e
4240
else:
43-
# Generate a new UUID if no context_id is provided.
4441
context_id = str(uuid.uuid4())
4542

4643
return Task(

0 commit comments

Comments
 (0)