FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Drop `AbstractAsyncContextManager` for proper type hint to `BaseSession` by Kludex · Pull Request #257 · modelcontextprotocol/python-sdk · GitHub

Drop AbstractAsyncContextManager for proper type hint to BaseSession - #257

Merged
dsp-ant merged 1 commit into
modelcontextprotocol:mainfrom
Kludex:drop-abstract-async-context-manager
Mar 11, 2025
Merged

Drop AbstractAsyncContextManager for proper type hint to BaseSession#257
dsp-ant merged 1 commit into
modelcontextprotocol:mainfrom
Kludex:drop-abstract-async-context-manager

Conversation

Kludex commented Mar 11, 2025

Copy link
Copy Markdown
Member

You can see that session assumes ClientSession type now.

from mcp.client.session import ClientSession


async def main():
    async with ClientSession() as session:
        await session.initialize()

The real problem is that AbstractAsyncContextManager is a generic, so it expects some type as an argument. We can't really add BaseClient as that type, because the return type from the ClientSession __aexit__ is not BaseClient, it's actually ClientSession.

Kludex changed the title Drop AbstractAsyncContextManager for proper type hints Drop AbstractAsyncContextManager for proper type hint to BaseSession Mar 11, 2025
Comment thread src/mcp/shared/session.py
import httpx
from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
from pydantic import BaseModel
from typing_extensions import Self

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Isn't this in typing as well?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

my bad, it's in typing in 3.11 not in 3.10

dsp-ant merged commit 3e0ab1e into modelcontextprotocol:main Mar 11, 2025
Kludex deleted the drop-abstract-async-context-manager branch March 11, 2025 13:17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL