Skip to content

Commit db9225b

Browse files
committed
fix: resolve pre-commit format and coverage issues
- Collapse super().__init__() to single line for ruff format - Add blank line after CursorCycleError class - Simplify cursor cycle test to eliminate uncovered branch - Add pragma: no branch for coverage.py false positive on nested async Fixes CI failures on PR #3156 Signed-off-by: dongjiang <dongjiang1989@126.com>
1 parent 931e9b6 commit db9225b

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

‎src/mcp/client/client.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ class PaginationExceededError(RuntimeError):
9696
"""
9797

9898
def __init__(self, method: str, max_pages: int) -> None:
99-
super().__init__(
100-
f"{method}: exceeded list_max_pages ({max_pages});"
101-
" server pagination did not terminate"
102-
)
99+
super().__init__(f"{method}: exceeded list_max_pages ({max_pages}); server pagination did not terminate")
103100
self.method = method
104101
self.max_pages = max_pages
105102

@@ -116,6 +113,7 @@ def __init__(self, method: str, cursor: str) -> None:
116113
self.method = method
117114
self.cursor = cursor
118115

116+
119117
_Connector = Callable[[AsyncExitStack, ConnectMode, bool], Awaitable["Dispatcher[Any]"]]
120118
"""Resolved at ``__post_init__`` from the shape of ``server`` alone: enter whatever resources
121119
are needed onto the exit stack and hand back the ``Dispatcher`` ``ClientSession`` will drive.

‎tests/client/test_list_all_pagination.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,14 @@ def dummy() -> str: # pragma: no cover
151151

152152
async with Client(server, mode="legacy", list_max_pages=0) as client:
153153
original = client.list_tools
154-
cursors = ["cursorA", "cursorB", "cursorA"] # cycle on 3rd call
154+
cursors_seq = ["cursorA", "cursorB", "cursorA", "cursorA", "cursorA"]
155155
call_count = 0
156156

157157
async def cycling_list_tools(*, cursor: str | None = None, **kwargs: object) -> ListToolsResult:
158158
nonlocal call_count
159-
result = await original(cursor=cursor, **kwargs)
160-
if call_count < len(cursors):
161-
result.next_cursor = cursors[call_count]
162159
call_count += 1
160+
result = await original(cursor=cursor, **kwargs)
161+
result.next_cursor = cursors_seq[call_count - 1] # pragma: no branch
163162
return result
164163

165164
client.list_tools = cycling_list_tools # type: ignore[method-assign]

0 commit comments

Comments
 (0)