mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
fix: resolve typos and add type annotations
- Fix typo in tui_app.py: key == key == curses.KEY_DOWN -> key == curses.KEY_DOWN - Add type annotations in send_message.py for better type checking
This commit is contained in:
@@ -122,10 +122,10 @@ class SendMessageToUserTool(FunctionTool[AstrAgentContext]):
|
||||
return path, False
|
||||
|
||||
async def call(
|
||||
self, context: ContextWrapper[AstrAgentContext], **kwargs
|
||||
self, context: ContextWrapper[AstrAgentContext], **kwargs: Any
|
||||
) -> ToolExecResult:
|
||||
session = kwargs.get("session") or context.context.event.unified_msg_origin
|
||||
messages = kwargs.get("messages")
|
||||
session: str | MessageSession = kwargs.get("session") or context.context.event.unified_msg_origin
|
||||
messages: list[dict[str, Any]] | None = kwargs.get("messages")
|
||||
|
||||
if not isinstance(messages, list) or not messages:
|
||||
return "error: messages parameter is empty or invalid."
|
||||
@@ -136,10 +136,9 @@ class SendMessageToUserTool(FunctionTool[AstrAgentContext]):
|
||||
if not isinstance(msg, dict):
|
||||
return f"error: messages[{idx}] should be an object."
|
||||
|
||||
typed_msg: MessageComponent = msg
|
||||
msg_type = str(typed_msg.get("type", "")).lower()
|
||||
if not msg_type:
|
||||
if "type" not in msg:
|
||||
return f"error: messages[{idx}].type is required."
|
||||
msg_type = str(msg["type"]).lower()
|
||||
|
||||
_file_from_sandbox = False
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ class AstrBotTUI:
|
||||
self._history_index += 1
|
||||
self.state.input_buffer = self._input_history[self._history_index]
|
||||
self.state.cursor_x = len(self.state.input_buffer)
|
||||
elif key == key == curses.KEY_DOWN:
|
||||
elif key == curses.KEY_DOWN:
|
||||
if self._history_index > 0:
|
||||
self._history_index -= 1
|
||||
self.state.input_buffer = self._input_history[self._history_index]
|
||||
|
||||
Reference in New Issue
Block a user