Skip to content

Commit c7b39d5

Browse files
committed
formatting and comments
1 parent 62930b2 commit c7b39d5

File tree

8 files changed

+59
-28
lines changed

8 files changed

+59
-28
lines changed

src/a2a/client/auth/interceptor.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ async def intercept(
6262
):
6363
headers['Authorization'] = f'Bearer {credential}'
6464
logger.debug(
65-
f"Added Bearer token for scheme '{scheme_name}' (type: {scheme_def.type})."
65+
"Added Bearer token for scheme '%s' (type: %s).",
66+
scheme_name,
67+
scheme_def.type,
6668
)
6769
http_kwargs['headers'] = headers
6870
return request_payload, http_kwargs
@@ -74,7 +76,9 @@ async def intercept(
7476
):
7577
headers['Authorization'] = f'Bearer {credential}'
7678
logger.debug(
77-
f"Added Bearer token for scheme '{scheme_name}' (type: {scheme_def.type})."
79+
"Added Bearer token for scheme '%s' (type: %s).",
80+
scheme_name,
81+
scheme_def.type,
7882
)
7983
http_kwargs['headers'] = headers
8084
return request_payload, http_kwargs
@@ -83,7 +87,8 @@ async def intercept(
8387
case APIKeySecurityScheme(in_=In.header):
8488
headers[scheme_def.name] = credential
8589
logger.debug(
86-
f"Added API Key Header for scheme '{scheme_name}'."
90+
"Added API Key Header for scheme '%s'.",
91+
scheme_name,
8792
)
8893
http_kwargs['headers'] = headers
8994
return request_payload, http_kwargs

src/a2a/server/apps/jsonrpc/jsonrpc_app.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,13 @@ def _generate_error_response(
233233
)
234234
logger.log(
235235
log_level,
236-
f'Request Error (ID: {request_id}): '
237-
f"Code={error_resp.error.code}, Message='{error_resp.error.message}'"
238-
f'{", Data=" + str(error_resp.error.data) if error_resp.error.data else ""}',
236+
"Request Error (ID: %s): Code=%s, Message='%s'%s",
237+
request_id,
238+
error_resp.error.code,
239+
error_resp.error.message,
240+
', Data=' + str(error_resp.error.data)
241+
if error_resp.error.data
242+
else '',
239243
)
240244
return JSONResponse(
241245
error_resp.model_dump(mode='json', exclude_none=True),
@@ -422,7 +426,7 @@ async def _process_non_streaming_request(
422426
)
423427
case _:
424428
logger.error(
425-
f'Unhandled validated request type: {type(request_obj)}'
429+
'Unhandled validated request type: %s', type(request_obj)
426430
)
427431
error = UnsupportedOperationError(
428432
message=f'Request type {type(request_obj).__name__} is unknown.'
@@ -497,8 +501,10 @@ async def _handle_get_agent_card(self, request: Request) -> JSONResponse:
497501
"""
498502
if request.url.path == PREV_AGENT_CARD_WELL_KNOWN_PATH:
499503
logger.warning(
500-
f"Deprecated agent card endpoint '{PREV_AGENT_CARD_WELL_KNOWN_PATH}' accessed. "
501-
f"Please use '{AGENT_CARD_WELL_KNOWN_PATH}' instead. This endpoint will be removed in a future version."
504+
"Deprecated agent card endpoint '%s' accessed. "
505+
"Please use '%s' instead. This endpoint will be removed in a future version.",
506+
PREV_AGENT_CARD_WELL_KNOWN_PATH,
507+
AGENT_CARD_WELL_KNOWN_PATH,
502508
)
503509

504510
card_to_serve = self.agent_card

src/a2a/server/request_handlers/default_request_handler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,9 @@ def _validate_task_id_match(self, task_id: str, event_task_id: str) -> None:
244244
"""Validates that agent-generated task ID matches the expected task ID."""
245245
if task_id != event_task_id:
246246
logger.error(
247-
f'Agent generated task_id={event_task_id} does not match the RequestContext task_id={task_id}.'
247+
'Agent generated task_id=%s does not match the RequestContext task_id=%s.',
248+
event_task_id,
249+
task_id,
248250
)
249251
raise ServerError(
250252
InternalError(message='Task ID mismatch in agent response')

src/a2a/server/tasks/base_push_notification_sender.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async def send_notification(self, task: Task) -> None:
4444

4545
if not all(results):
4646
logger.warning(
47-
f'Some push notifications failed to send for task_id={task.id}'
47+
'Some push notifications failed to send for task_id=%s', task.id
4848
)
4949

5050
async def _dispatch_notification(
@@ -62,11 +62,13 @@ async def _dispatch_notification(
6262
)
6363
response.raise_for_status()
6464
logger.info(
65-
f'Push-notification sent for task_id={task.id} to URL: {url}'
65+
'Push-notification sent for task_id=%s to URL: %s', task.id, url
6666
)
6767
except Exception:
6868
logger.exception(
69-
f'Error sending push-notification for task_id={task.id} to URL: {url}.'
69+
'Error sending push-notification for task_id=%s to URL: %s.',
70+
task.id,
71+
url,
7072
)
7173
return False
7274
return True

src/a2a/server/tasks/database_push_notification_config_store.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ def __init__(
7878
The key must be a URL-safe base64-encoded 32-byte key.
7979
"""
8080
logger.debug(
81-
f'Initializing DatabasePushNotificationConfigStore with existing engine, table: {table_name}'
81+
'Initializing DatabasePushNotificationConfigStore with existing engine, table: %s',
82+
table_name,
8283
)
8384
self.engine = engine
8485
self.async_session_maker = async_sessionmaker(
@@ -235,7 +236,9 @@ async def set_info(
235236
async with self.async_session_maker.begin() as session:
236237
await session.merge(db_config)
237238
logger.debug(
238-
f'Push notification config for task {task_id} with config id {config_to_save.id} saved/updated.'
239+
'Push notification config for task %s with config id %s saved/updated.',
240+
task_id,
241+
config_to_save.id,
239242
)
240243

241244
async def get_info(self, task_id: str) -> list[PushNotificationConfig]:
@@ -280,9 +283,13 @@ async def delete_info(
280283

281284
if result.rowcount > 0:
282285
logger.info(
283-
f'Deleted {result.rowcount} push notification config(s) for task {task_id}.'
286+
'Deleted %s push notification config(s) for task %s.',
287+
result.rowcount,
288+
task_id,
284289
)
285290
else:
286291
logger.warning(
287-
f'Attempted to delete push notification config for task {task_id} with config_id: {config_id} that does not exist.'
292+
'Attempted to delete push notification config for task %s with config_id: %s that does not exist.',
293+
task_id,
294+
config_id,
288295
)

src/a2a/server/tasks/database_task_store.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ def __init__(
5353
table_name: Name of the database table. Defaults to 'tasks'.
5454
"""
5555
logger.debug(
56-
f'Initializing DatabaseTaskStore with existing engine, table: {table_name}'
56+
'Initializing DatabaseTaskStore with existing engine, table: %s',
57+
table_name,
5758
)
5859
self.engine = engine
5960
self.async_session_maker = async_sessionmaker(

src/a2a/utils/error_handlers.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ async def wrapper(*args: Any, **kwargs: Any) -> Response:
7373
)
7474
logger.log(
7575
log_level,
76-
'Request error: '
77-
f"Code={error.code}, Message='{error.message}'"
78-
f'{", Data=" + str(error.data) if error.data else ""}',
76+
"Request error: Code=%s, Message='%s'%s",
77+
error.code,
78+
error.message,
79+
', Data=' + str(error.data) if error.data else '',
7980
)
8081
return JSONResponse(
8182
content={'message': error.message}, status_code=http_code
@@ -110,9 +111,10 @@ async def wrapper(*args: Any, **kwargs: Any) -> Any:
110111
)
111112
logger.log(
112113
log_level,
113-
'Request error: '
114-
f"Code={error.code}, Message='{error.message}'"
115-
f'{", Data=" + str(error.data) if error.data else ""}',
114+
"Request error: Code=%s, Message='%s'%s",
115+
error.code,
116+
error.message,
117+
', Data=' + str(error.data) if error.data else '',
116118
)
117119
# Since the stream has started, we can't return a JSONResponse.
118120
# Instead, we runt the error handling logic (provides logging)

src/a2a/utils/helpers.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,32 @@ def append_artifact_to_task(task: Task, event: TaskArtifactUpdateEvent) -> None:
8181
if existing_artifact_list_index is not None:
8282
# Replace the existing artifact entirely with the new data
8383
logger.debug(
84-
f'Replacing artifact at id {artifact_id} for task {task.id}'
84+
'Replacing artifact at id %s for task %s', artifact_id, task.id
8585
)
8686
task.artifacts[existing_artifact_list_index] = new_artifact_data
8787
else:
8888
# Append the new artifact since no artifact with this index exists yet
8989
logger.debug(
90-
f'Adding new artifact with id {artifact_id} for task {task.id}'
90+
'Adding new artifact with id %s for task %s',
91+
artifact_id,
92+
task.id,
9193
)
9294
task.artifacts.append(new_artifact_data)
9395
elif existing_artifact:
9496
# Append new parts to the existing artifact's part list
9597
logger.debug(
96-
f'Appending parts to artifact id {artifact_id} for task {task.id}'
98+
'Appending parts to artifact id %s for task %s',
99+
artifact_id,
100+
task.id,
97101
)
98102
existing_artifact.parts.extend(new_artifact_data.parts)
99103
else:
100104
# We received a chunk to append, but we don't have an existing artifact.
101105
# we will ignore this chunk
102106
logger.warning(
103-
f'Received append=True for nonexistent artifact index {artifact_id} in task {task.id}. Ignoring chunk.'
107+
'Received append=True for nonexistent artifact index %s in task %s. Ignoring chunk.',
108+
artifact_id,
109+
task.id,
104110
)
105111

106112

0 commit comments

Comments
 (0)