Skip to content

Commit f8ae67d

Browse files
committed
Add lint fixes
1 parent 29f1041 commit f8ae67d

File tree

11 files changed

+36
-49
lines changed

11 files changed

+36
-49
lines changed

scripts/grpc_gen_post_processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def process_generated_code(src_folder: str = 'src/a2a/grpc') -> None:
4747
else:
4848
print('No changes needed')
4949

50-
except Exception as e:
50+
except Exception as e: # noqa: BLE001
5151
print(f'Error processing file {file}: {e}')
5252
sys.exit(1)
5353

src/a2a/extensions/__init__.py

Whitespace-only changes.

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,7 @@ async def _handle_requests(self, request: Request) -> Response: # noqa: PLR0911
317317
)
318318
raise e
319319
except Exception as e:
320-
logger.exception(f'Unhandled exception: {e}')
321-
traceback.print_exc()
320+
logger.exception('Unhandled exception')
322321
return self._generate_error_response(
323322
request_id, A2AError(root=InternalError(message=str(e)))
324323
)

src/a2a/server/events/event_consumer.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,11 @@ async def consume_all(self) -> AsyncGenerator[Event]:
140140
# python 3.12 and get a queue empty error on an open queue
141141
if self.queue.is_closed():
142142
break
143-
except ValidationError as e:
144-
logger.exception(f'Invalid event format received: {e}')
143+
except ValidationError:
144+
logger.exception('Invalid event format received')
145145
continue
146146
except Exception as e:
147-
logger.exception(
148-
f'Stopping event consumption due to exception: {e}'
149-
)
147+
logger.exception('Stopping event consumption due to exception')
150148
self._exception = e
151149
continue
152150

src/a2a/server/events/event_queue.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@ async def close(self) -> None:
147147
# Otherwise, join the queue
148148
else:
149149
tasks = [asyncio.create_task(self.queue.join())]
150-
for child in self._children:
151-
tasks.append(asyncio.create_task(child.close()))
150+
tasks.extend(
151+
asyncio.create_task(child.close()) for child in self._children
152+
)
152153
await asyncio.wait(tasks, return_when=asyncio.ALL_COMPLETED)
153154

154155
def is_closed(self) -> bool:

src/a2a/server/request_handlers/default_request_handler.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ async def on_message_send(
302302
task_id, result_aggregator
303303
)
304304

305-
except Exception as e:
306-
logger.exception(f'Agent execution failed. Error: {e}')
305+
except Exception:
306+
logger.exception('Agent execution failed')
307307
raise
308308
finally:
309309
if interrupted_or_non_blocking:
@@ -478,16 +478,12 @@ async def on_list_task_push_notification_config(
478478
params.id
479479
)
480480

481-
task_push_notification_config = []
482-
if push_notification_config_list:
483-
for config in push_notification_config_list:
484-
task_push_notification_config.append(
485-
TaskPushNotificationConfig(
486-
task_id=params.id, push_notification_config=config
487-
)
488-
)
489-
490-
return task_push_notification_config
481+
return [
482+
TaskPushNotificationConfig(
483+
task_id=params.id, push_notification_config=config
484+
)
485+
for config in push_notification_config_list
486+
]
491487

492488
async def on_delete_task_push_notification_config(
493489
self,

src/a2a/server/tasks/base_push_notification_sender.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ async def _dispatch_notification(
6464
logger.info(
6565
f'Push-notification sent for task_id={task.id} to URL: {url}'
6666
)
67-
return True
68-
except Exception as e:
67+
except Exception:
6968
logger.exception(
70-
f'Error sending push-notification for task_id={task.id} to URL: {url}. Error: {e}'
69+
f'Error sending push-notification for task_id={task.id} to URL: {url}.'
7170
)
7271
return False
72+
return True

src/a2a/server/tasks/database_push_notification_config_store.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,11 @@ async def get_info(self, task_id: str) -> list[PushNotificationConfig]:
252252
for model in models:
253253
try:
254254
configs.append(self._from_orm(model))
255-
except ValueError as e:
255+
except ValueError:
256256
logger.exception(
257-
'Could not deserialize push notification config for task %s, config %s: %s',
257+
'Could not deserialize push notification config for task %s, config %s',
258258
model.task_id,
259259
model.config_id,
260-
e,
261260
)
262261
return configs
263262

src/a2a/utils/error_handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ async def wrapper(*args: Any, **kwargs: Any) -> Response:
8080
return JSONResponse(
8181
content={'message': error.message}, status_code=http_code
8282
)
83-
except Exception as e:
83+
except Exception as e: # noqa: BLE001
8484
logger.log(logging.ERROR, f'Unknown error occurred {e}')
8585
return JSONResponse(
8686
content={'message': 'unknown exception'}, status_code=500

src/a2a/utils/proto_utils.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -338,16 +338,12 @@ def security(
338338
) -> list[a2a_pb2.Security] | None:
339339
if not security:
340340
return None
341-
rval: list[a2a_pb2.Security] = []
342-
for s in security:
343-
rval.append(
344-
a2a_pb2.Security(
345-
schemes={
346-
k: a2a_pb2.StringList(list=v) for (k, v) in s.items()
347-
}
348-
)
341+
return [
342+
a2a_pb2.Security(
343+
schemes={k: a2a_pb2.StringList(list=v) for (k, v) in s.items()}
349344
)
350-
return rval
345+
for s in security
346+
]
351347

352348
@classmethod
353349
def security_schemes(
@@ -774,10 +770,9 @@ def security(
774770
) -> list[dict[str, list[str]]] | None:
775771
if not security:
776772
return None
777-
rval: list[dict[str, list[str]]] = []
778-
for s in security:
779-
rval.append({k: list(v.list) for (k, v) in s.schemes.items()})
780-
return rval
773+
return [
774+
{k: list(v.list) for (k, v) in s.schemes.items()} for s in security
775+
]
781776

782777
@classmethod
783778
def provider(

0 commit comments

Comments
 (0)