Skip to content

Commit 4abb5c2

Browse files
committed
style: Apply ruff formatting fixes from pre-commit
1 parent 236a041 commit 4abb5c2

File tree

2 files changed

+15
-41
lines changed

2 files changed

+15
-41
lines changed

src/mcp/client/stdio/__init__.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,7 @@ async def stdio_client(server: StdioServerParameters, errlog: TextIO = sys.stder
123123
process = await _create_platform_compatible_process(
124124
command=command,
125125
args=server.args,
126-
env=(
127-
{**get_default_environment(), **server.env}
128-
if server.env is not None
129-
else get_default_environment()
130-
),
126+
env=({**get_default_environment(), **server.env} if server.env is not None else get_default_environment()),
131127
errlog=errlog,
132128
cwd=server.cwd,
133129
)
@@ -171,9 +167,7 @@ async def stdin_writer():
171167
try:
172168
async with write_stream_reader:
173169
async for session_message in write_stream_reader:
174-
json = session_message.message.model_dump_json(
175-
by_alias=True, exclude_none=True
176-
)
170+
json = session_message.message.model_dump_json(by_alias=True, exclude_none=True)
177171
await process.stdin.send(
178172
(json + "\n").encode(
179173
encoding=server.encoding,
@@ -259,9 +253,7 @@ async def _create_platform_compatible_process(
259253
return process
260254

261255

262-
async def _terminate_process_tree(
263-
process: Process | FallbackProcess, timeout_seconds: float = 2.0
264-
) -> None:
256+
async def _terminate_process_tree(process: Process | FallbackProcess, timeout_seconds: float = 2.0) -> None:
265257
"""
266258
Terminate a process and all its children using platform-specific methods.
267259

tests/server/fastmcp/test_integration.py

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ def run_server_with_transport(module_name: str, port: int, transport: str) -> No
8989
import os
9090

9191
# Add examples/snippets to Python path for multiprocessing context
92-
snippets_path = os.path.join(
93-
os.path.dirname(__file__), "..", "..", "..", "examples", "snippets"
94-
)
92+
snippets_path = os.path.join(os.path.dirname(__file__), "..", "..", "..", "examples", "snippets")
9593
sys.path.insert(0, os.path.abspath(snippets_path))
9694

9795
# Import the servers module in the multiprocessing context
@@ -140,9 +138,7 @@ def run_server_with_transport(module_name: str, port: int, transport: str) -> No
140138
else:
141139
raise ValueError(f"Invalid transport for test server: {transport}")
142140

143-
server = uvicorn.Server(
144-
config=uvicorn.Config(app=app, host="127.0.0.1", port=port, log_level="error")
145-
)
141+
server = uvicorn.Server(config=uvicorn.Config(app=app, host="127.0.0.1", port=port, log_level="error"))
146142
print(f"Starting {transport} server on port {port}")
147143
server.run()
148144

@@ -350,14 +346,10 @@ async def test_basic_prompts(server_transport: str, server_url: str) -> None:
350346

351347
# Test review_code prompt
352348
prompts = await session.list_prompts()
353-
review_prompt = next(
354-
(p for p in prompts.prompts if p.name == "review_code"), None
355-
)
349+
review_prompt = next((p for p in prompts.prompts if p.name == "review_code"), None)
356350
assert review_prompt is not None
357351

358-
prompt_result = await session.get_prompt(
359-
"review_code", {"code": "def hello():\n print('Hello')"}
360-
)
352+
prompt_result = await session.get_prompt("review_code", {"code": "def hello():\n print('Hello')"})
361353
assert isinstance(prompt_result, GetPromptResult)
362354
assert len(prompt_result.messages) == 1
363355
assert isinstance(prompt_result.messages[0].content, TextContent)
@@ -413,18 +405,16 @@ async def test_tool_progress(server_transport: str, server_url: str) -> None:
413405
assert result.capabilities.tools is not None
414406

415407
# Test long_running_task tool that reports progress
416-
tool_result = await session.call_tool(
417-
"long_running_task", {"task_name": "test", "steps": 3}
418-
)
408+
tool_result = await session.call_tool("long_running_task", {"task_name": "test", "steps": 3})
419409
assert len(tool_result.content) == 1
420410
assert isinstance(tool_result.content[0], TextContent)
421411
assert "Task 'test' completed" in tool_result.content[0].text
422412

423413
# Verify that progress notifications or log messages were sent
424414
# Progress can come through either progress notifications or log messages
425-
total_notifications = len(
426-
notification_collector.progress_notifications
427-
) + len(notification_collector.log_messages)
415+
total_notifications = len(notification_collector.progress_notifications) + len(
416+
notification_collector.log_messages
417+
)
428418
assert total_notifications > 0
429419

430420

@@ -445,9 +435,7 @@ async def test_sampling(server_transport: str, server_url: str) -> None:
445435

446436
async with client_cm as client_streams:
447437
read_stream, write_stream = unpack_streams(client_streams)
448-
async with ClientSession(
449-
read_stream, write_stream, sampling_callback=sampling_callback
450-
) as session:
438+
async with ClientSession(read_stream, write_stream, sampling_callback=sampling_callback) as session:
451439
# Test initialization
452440
result = await session.initialize()
453441
assert isinstance(result, InitializeResult)
@@ -478,9 +466,7 @@ async def test_elicitation(server_transport: str, server_url: str) -> None:
478466

479467
async with client_cm as client_streams:
480468
read_stream, write_stream = unpack_streams(client_streams)
481-
async with ClientSession(
482-
read_stream, write_stream, elicitation_callback=elicitation_callback
483-
) as session:
469+
async with ClientSession(read_stream, write_stream, elicitation_callback=elicitation_callback) as session:
484470
# Test initialization
485471
result = await session.initialize()
486472
assert isinstance(result, InitializeResult)
@@ -526,9 +512,7 @@ async def test_completion(server_transport: str, server_url: str) -> None:
526512
assert len(prompts.prompts) > 0
527513

528514
# Test getting a prompt
529-
prompt_result = await session.get_prompt(
530-
"review_code", {"language": "python", "code": "def test(): pass"}
531-
)
515+
prompt_result = await session.get_prompt("review_code", {"language": "python", "code": "def test(): pass"})
532516
assert len(prompt_result.messages) > 0
533517

534518

@@ -640,9 +624,7 @@ async def test_structured_output(server_transport: str, server_url: str) -> None
640624
assert result.serverInfo.name == "Structured Output Example"
641625

642626
# Test get_weather tool
643-
weather_result = await session.call_tool(
644-
"get_weather", {"city": "New York"}
645-
)
627+
weather_result = await session.call_tool("get_weather", {"city": "New York"})
646628
assert len(weather_result.content) == 1
647629
assert isinstance(weather_result.content[0], TextContent)
648630

0 commit comments

Comments
 (0)