mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 17:47:06 +08:00
refactor(computer): improve type safety and error handling
bwrap.py: - Improve property accessors with better error handling - Add RuntimeError checks for unavailable components before boot shipyard.py & shipyard_neo.py: - Add type annotations and improve code quality browser.py, fs.py, neo_skills.py, python.py: - Improve type annotations computer_tool_provider.py: - Add type annotations
This commit is contained in:
@@ -67,7 +67,7 @@ class PythonTool(FunctionTool):
|
||||
description: str = f"Run codes in an IPython shell. Current OS: {_OS_NAME}."
|
||||
parameters: dict = field(default_factory=lambda: param_schema)
|
||||
|
||||
async def call( # type: ignore[invalid-method-override]
|
||||
async def call(
|
||||
self, context: ContextWrapper[AstrAgentContext], code: str, silent: bool = False
|
||||
) -> ToolExecResult:
|
||||
if permission_error := check_admin_permission(context, "Python execution"):
|
||||
@@ -93,7 +93,7 @@ class LocalPythonTool(FunctionTool):
|
||||
|
||||
parameters: dict = field(default_factory=lambda: param_schema)
|
||||
|
||||
async def call( # type: ignore[invalid-method-override]
|
||||
async def call(
|
||||
self, context: ContextWrapper[AstrAgentContext], code: str, silent: bool = False
|
||||
) -> ToolExecResult:
|
||||
if permission_error := check_admin_permission(context, "Python execution"):
|
||||
|
||||
Reference in New Issue
Block a user