Skip to content

Commit 3e0ab1e

Browse files
authored
Drop AbstractAsyncContextManager for proper type hints (#257)
1 parent 5cbea24 commit 3e0ab1e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: src/mcp/shared/session.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import httpx
99
from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
1010
from pydantic import BaseModel
11+
from typing_extensions import Self
1112

1213
from mcp.shared.exceptions import McpError
1314
from mcp.types import (
@@ -60,7 +61,7 @@ def __init__(
6061
request_id: RequestId,
6162
request_meta: RequestParams.Meta | None,
6263
request: ReceiveRequestT,
63-
session: "BaseSession",
64+
session: "BaseSession[SendRequestT, SendNotificationT, SendResultT, ReceiveRequestT, ReceiveNotificationT]",
6465
on_complete: Callable[["RequestResponder[ReceiveRequestT, SendResultT]"], Any],
6566
) -> None:
6667
self.request_id = request_id
@@ -134,7 +135,6 @@ def cancelled(self) -> bool:
134135

135136

136137
class BaseSession(
137-
AbstractAsyncContextManager,
138138
Generic[
139139
SendRequestT,
140140
SendNotificationT,
@@ -183,7 +183,7 @@ def __init__(
183183
]()
184184
)
185185

186-
async def __aenter__(self):
186+
async def __aenter__(self) -> Self:
187187
self._task_group = anyio.create_task_group()
188188
await self._task_group.__aenter__()
189189
self._task_group.start_soon(self._receive_loop)

0 commit comments

Comments
 (0)