Skip to content

Commit cb507b0

Browse files
mgoldsboroughclaude
andcommitted
Fix ruff formatting in api_models.py and test_server.py
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 453e017 commit cb507b0

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

src/mcp_example/api_models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ class Pagination(BaseModel):
1818

1919
model_config = {"populate_by_name": True}
2020

21-
next_cursor: str | None = Field(default=None, alias="nextCursor", description="Next page cursor")
21+
next_cursor: str | None = Field(
22+
default=None, alias="nextCursor", description="Next page cursor"
23+
)
2224
has_more: bool = Field(default=False, alias="hasMore", description="Whether more pages exist")
2325

2426

tests/test_server.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@
1010
def mock_client():
1111
"""Create a mock API client."""
1212
client = AsyncMock()
13-
client.list_items = AsyncMock(return_value=[
14-
{"id": "1", "name": "Item 1"},
15-
{"id": "2", "name": "Item 2"},
16-
])
17-
client.get_item = AsyncMock(return_value={
18-
"id": "1",
19-
"name": "Item 1",
20-
"description": "Test item",
21-
})
13+
client.list_items = AsyncMock(
14+
return_value=[
15+
{"id": "1", "name": "Item 1"},
16+
{"id": "2", "name": "Item 2"},
17+
]
18+
)
19+
client.get_item = AsyncMock(
20+
return_value={
21+
"id": "1",
22+
"name": "Item 1",
23+
"description": "Test item",
24+
}
25+
)
2226
return client
2327

2428

@@ -27,6 +31,7 @@ async def test_list_items(mock_client):
2731
"""Test list_items tool."""
2832
with patch("mcp_example.server.get_client", return_value=mock_client):
2933
from mcp_example.server import list_items
34+
3035
result = await list_items(limit=10)
3136
assert len(result) == 2
3237
mock_client.list_items.assert_called_once_with(limit=10)
@@ -37,6 +42,7 @@ async def test_get_item(mock_client):
3742
"""Test get_item tool."""
3843
with patch("mcp_example.server.get_client", return_value=mock_client):
3944
from mcp_example.server import get_item
45+
4046
result = await get_item(item_id="1")
4147
assert result["id"] == "1"
4248
mock_client.get_item.assert_called_once_with("1")
@@ -45,10 +51,9 @@ async def test_get_item(mock_client):
4551
@pytest.mark.asyncio
4652
async def test_list_items_api_error(mock_client):
4753
"""Test list_items handles API errors."""
48-
mock_client.list_items = AsyncMock(
49-
side_effect=ExampleAPIError(401, "Unauthorized")
50-
)
54+
mock_client.list_items = AsyncMock(side_effect=ExampleAPIError(401, "Unauthorized"))
5155
with patch("mcp_example.server.get_client", return_value=mock_client):
5256
from mcp_example.server import list_items
57+
5358
with pytest.raises(ExampleAPIError):
5459
await list_items()

0 commit comments

Comments
 (0)