Skip to content

Commit ffc535f

Browse files
committed
chore(core.agent): ruff rewrite
1 parent 8b6d235 commit ffc535f

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

astrbot/core/agent/mcp_client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import asyncio
22
import logging
33
from datetime import timedelta
4-
from typing import Optional
54
from contextlib import AsyncExitStack
65
from astrbot import logger
76
from astrbot.core.utils.log_pipe import LogPipe
@@ -96,7 +95,7 @@ async def _quick_test_mcp_connection(config: dict) -> tuple[bool, str]:
9695
class MCPClient:
9796
def __init__(self):
9897
# Initialize session and client objects
99-
self.session: Optional[mcp.ClientSession] = None
98+
self.session: mcp.ClientSession | None = None
10099
self.exit_stack = AsyncExitStack()
101100

102101
self.name: str | None = None

astrbot/core/agent/tool.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from dataclasses import dataclass
22
from deprecated import deprecated
3-
from typing import Awaitable, Callable, Literal, Any, Optional
3+
from typing import Literal, Any
4+
5+
from collections.abc import Awaitable, Callable
46
from .mcp_client import MCPClient
57

68

@@ -71,7 +73,7 @@ def remove_tool(self, name: str):
7173
"""Remove a tool by its name."""
7274
self.tools = [tool for tool in self.tools if tool.name != name]
7375

74-
def get_tool(self, name: str) -> Optional[FunctionTool]:
76+
def get_tool(self, name: str) -> FunctionTool | None:
7577
"""Get a tool by its name."""
7678
for tool in self.tools:
7779
if tool.name == name:

astrbot/core/agent/tool_executor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import mcp
2-
from typing import Any, Generic, AsyncGenerator
2+
from typing import Any, Generic
3+
4+
from collections.abc import AsyncGenerator
35
from .run_context import TContext, ContextWrapper
46
from .tool import FunctionTool
57

0 commit comments

Comments
 (0)