Skip to content

Commit 1bed85b

Browse files
committed
ci(lint): align tests with ruff format so pipeline passes
1 parent 6a1a045 commit 1bed85b

File tree

4 files changed

+39
-28
lines changed

4 files changed

+39
-28
lines changed

examples/redis_assistant.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ async def build_agent():
1212
params={
1313
"command": "uv",
1414
"args": [
15-
"--directory", "../src/", # change with the path to the MCP server
16-
"run", "main.py"
15+
"--directory",
16+
"../src/", # change with the path to the MCP server
17+
"run",
18+
"main.py",
1719
],
18-
"env": {
19-
"REDIS_HOST": "127.0.0.1",
20-
"REDIS_PORT": "6379",
21-
"REDIS_USERNAME": "default",
22-
"REDIS_PWD": ""
23-
},
20+
"env": {
21+
"REDIS_HOST": "127.0.0.1",
22+
"REDIS_PORT": "6379",
23+
"REDIS_USERNAME": "default",
24+
"REDIS_PWD": "",
25+
},
2426
}
2527
)
2628

@@ -30,7 +32,7 @@ async def build_agent():
3032
agent = Agent(
3133
name="Redis Assistant",
3234
instructions="You are a helpful assistant capable of reading and writing to Redis. Store every question and answer in the Redis Stream app:logger",
33-
mcp_servers=[server]
35+
mcp_servers=[server],
3436
)
3537

3638
return agent
@@ -46,7 +48,7 @@ async def cli(agent, max_history=30):
4648
if q.strip().lower() in {"exit", "quit"}:
4749
break
4850

49-
if (len(q.strip()) > 0):
51+
if len(q.strip()) > 0:
5052
# Format the context into a single string
5153
history = ""
5254
for turn in conversation_history:
@@ -58,7 +60,9 @@ async def cli(agent, max_history=30):
5860

5961
response_text = ""
6062
async for event in result.stream_events():
61-
if event.type == "raw_response_event" and isinstance(event.data, ResponseTextDeltaEvent):
63+
if event.type == "raw_response_event" and isinstance(
64+
event.data, ResponseTextDeltaEvent
65+
):
6266
print(event.data.delta, end="", flush=True)
6367
response_text += event.data.delta
6468
print("\n")

tests/test_integration.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ def test_server_lists_tools(self, server_process):
240240
"get",
241241
]
242242
for tool in tool_names:
243-
assert (
244-
tool in expected_tools
245-
), f"Expected tool '{tool}' not found in {tool_names}"
243+
assert tool in expected_tools, (
244+
f"Expected tool '{tool}' not found in {tool_names}"
245+
)
246246

247247
def test_server_tool_count_and_names(self, server_process):
248248
"""Test that the server registers the correct number of tools with expected names."""
@@ -269,9 +269,9 @@ def test_server_tool_count_and_names(self, server_process):
269269

270270
# Expected tool count (based on @mcp.tool() decorators in codebase)
271271
expected_tool_count = 44
272-
assert (
273-
len(tools) == expected_tool_count
274-
), f"Expected {expected_tool_count} tools, but got {len(tools)}"
272+
assert len(tools) == expected_tool_count, (
273+
f"Expected {expected_tool_count} tools, but got {len(tools)}"
274+
)
275275

276276
# Expected tool names (alphabetically sorted for easier verification)
277277
expected_tools = [
@@ -360,9 +360,9 @@ def test_server_tool_count_and_names(self, server_process):
360360

361361
for category, category_tools in tool_categories.items():
362362
for tool in category_tools:
363-
assert (
364-
tool in tool_names
365-
), f"Tool '{tool}' from category '{category}' not found in registered tools"
363+
assert tool in tool_names, (
364+
f"Tool '{tool}' from category '{category}' not found in registered tools"
365+
)
366366

367367
def _initialize_server(self, server_process):
368368
"""Helper to initialize the MCP server."""

tests/test_logging_utils.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ def test_configure_logging_adds_stderr_handler_when_none(monkeypatch, preserve_l
6868
level = configure_logging()
6969

7070
assert level == logging.INFO
71-
assert len(root.handlers) == 1, "Should add exactly one stderr handler when none exist"
71+
assert len(root.handlers) == 1, (
72+
"Should add exactly one stderr handler when none exist"
73+
)
7274
handler = root.handlers[0]
7375
assert isinstance(handler, logging.StreamHandler)
7476
# StreamHandler exposes the underlying stream attribute
@@ -77,7 +79,9 @@ def test_configure_logging_adds_stderr_handler_when_none(monkeypatch, preserve_l
7779
assert root.level == logging.INFO
7880

7981

80-
def test_configure_logging_only_lowers_restrictive_handlers(monkeypatch, preserve_logging):
82+
def test_configure_logging_only_lowers_restrictive_handlers(
83+
monkeypatch, preserve_logging
84+
):
8185
root = logging.getLogger()
8286
# Start from a clean handler set
8387
for h in list(root.handlers):
@@ -101,7 +105,9 @@ def test_configure_logging_only_lowers_restrictive_handlers(monkeypatch, preserv
101105
assert h_notset.level == logging.NOTSET
102106

103107

104-
def test_configure_logging_does_not_raise_handler_threshold(monkeypatch, preserve_logging):
108+
def test_configure_logging_does_not_raise_handler_threshold(
109+
monkeypatch, preserve_logging
110+
):
105111
root = logging.getLogger()
106112
# Clean handlers
107113
for h in list(root.handlers):
@@ -121,7 +127,9 @@ def test_configure_logging_does_not_raise_handler_threshold(monkeypatch, preserv
121127
assert root.level == logging.ERROR
122128

123129

124-
def test_configure_logging_does_not_add_handler_if_exists(monkeypatch, preserve_logging):
130+
def test_configure_logging_does_not_add_handler_if_exists(
131+
monkeypatch, preserve_logging
132+
):
125133
root = logging.getLogger()
126134
# Start with one existing handler
127135
for h in list(root.handlers):
@@ -135,4 +143,3 @@ def test_configure_logging_does_not_add_handler_if_exists(monkeypatch, preserve_
135143
# Should not add another handler
136144
assert len(root.handlers) == 1
137145
assert root.handlers[0] is existing
138-

tests/test_server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,6 @@ def test_mcp_server_attributes(self):
127127

128128
for attr in expected_attributes:
129129
assert hasattr(mcp, attr), f"MCP server missing attribute: {attr}"
130-
assert callable(
131-
getattr(mcp, attr)
132-
), f"MCP server attribute {attr} is not callable"
130+
assert callable(getattr(mcp, attr)), (
131+
f"MCP server attribute {attr} is not callable"
132+
)

0 commit comments

Comments
 (0)