Skip to content

Commit 6212a64

Browse files
committed
fix: add pragma no cover to Protocol stubs and unreachable mock branch
Protocol stub methods (fetch_token, create_authorization_url, ensure_active_token) have Ellipsis bodies that coverage flags as uncovered branches because Protocol classes are never instantiated. Mark them with pragma: no cover. The fallback path in _mock_iterdir (returning original_iterdir when the path does not contain "fake") is only reachable on Windows where jsonschema lazily loads schemas during the test. On Linux/macOS jsonschema loads schemas eagerly so the branch is never taken. Mark it accordingly.
1 parent e9c4405 commit 6212a64

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/mcp/client/auth/authlib_adapter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ class _AsyncOAuth2ClientProtocol(Protocol):
6464
scope: str | None
6565
code_challenge_method: str
6666

67-
async def fetch_token(self, url: str, **kwargs: Any) -> dict[str, Any]: ...
67+
async def fetch_token(self, url: str, **kwargs: Any) -> dict[str, Any]: ... # pragma: no cover
6868

69-
def create_authorization_url(self, url: str, **kwargs: Any) -> tuple[str, str]: ...
69+
def create_authorization_url(self, url: str, **kwargs: Any) -> tuple[str, str]: ... # pragma: no cover
7070

71-
async def ensure_active_token(self, token: dict[str, Any]) -> None: ...
71+
async def ensure_active_token(self, token: dict[str, Any]) -> None: ... # pragma: no cover
7272

7373

7474
# ---------------------------------------------------------------------------

tests/test_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def _mock_iterdir(self: Path) -> object:
7676
# loading (which also calls Path.iterdir) is not affected on any platform.
7777
if "fake" in str(self):
7878
return mock_files
79-
return original_iterdir(self) # type: ignore[reportUnknownArgumentType]
79+
return original_iterdir(self) # pragma: no cover
8080

8181
monkeypatch.setattr(Path, "iterdir", _mock_iterdir)
8282
monkeypatch.setattr(Path, "home", lambda: Path("/fake/home"))

0 commit comments

Comments
 (0)