refactor: replace try-except blocks with contextlib.suppress for cleaner error handling across multiple files
This commit is contained in:
@@ -5,6 +5,7 @@ from __future__ import annotations
|
||||
import asyncio
|
||||
import inspect
|
||||
import os
|
||||
from contextlib import suppress
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
@@ -752,12 +753,10 @@ class AgentRunner:
|
||||
prepare_call = getattr(spec.tools, "prepare_call", None)
|
||||
tool, params, prep_error = None, tool_call.arguments, None
|
||||
if callable(prepare_call):
|
||||
try:
|
||||
with suppress(Exception):
|
||||
prepared = prepare_call(tool_call.name, tool_call.arguments)
|
||||
if isinstance(prepared, tuple) and len(prepared) == 3:
|
||||
tool, params, prep_error = prepared
|
||||
except Exception:
|
||||
pass
|
||||
if prep_error:
|
||||
event = {
|
||||
"name": tool_call.name,
|
||||
|
||||
Reference in New Issue
Block a user