Skip to content

Commit c14ec2e

Browse files
committed
fix typing issues
1 parent 059e831 commit c14ec2e

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

examples/clients/simple-chatbot/mcp_simple_chatbot/main.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,15 @@ async def initialize(self) -> None:
9191
else None,
9292
)
9393
try:
94-
stdio_transport = await self.exit_stack.enter_async_context(stdio_client(server_params))
94+
stdio_transport = await self.exit_stack.enter_async_context(
95+
stdio_client(server_params)
96+
)
9597
read, write = stdio_transport
96-
self.session = await self.exit_stack.enter_async_context(ClientSession(read, write))
97-
await self.session.initialize()
98+
session = await self.exit_stack.enter_async_context(
99+
ClientSession(read, write)
100+
)
101+
await session.initialize()
102+
self.session = session
98103
except Exception as e:
99104
logging.error(f"Error initializing server {self.name}: {e}")
100105
await self.cleanup()
@@ -257,7 +262,7 @@ def get_response(self, messages: list[dict[str, str]]) -> str:
257262
error_message = f"Error getting LLM response: {str(e)}"
258263
logging.error(error_message)
259264

260-
if hasattr(e, 'response'):
265+
if isinstance(e, httpx.HTTPStatusError):
261266
status_code = e.response.status_code
262267
logging.error(f"Status code: {status_code}")
263268
logging.error(f"Response details: {e.response.text}")

examples/clients/simple-chatbot/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ line-length = 88
4545
target-version = "py310"
4646

4747
[tool.uv]
48-
dev-dependencies = ["pyright>=1.1.378", "pytest>=8.3.3", "ruff>=0.6.9"]
48+
dev-dependencies = ["pyright>=1.1.379", "pytest>=8.3.3", "ruff>=0.6.9"]

0 commit comments

Comments
 (0)