ci: add strict-no-cover to detect unnecessary coverage pragmas (#1897)

This commit is contained in:
Max Isbey 2026-01-23 20:00:20 +00:00 • committed by GitHub
commit a7ddfdae07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 355 additions and 358 deletions

View file

@ -23,7 +23,7 @@ class MockTokenStorage:
self._tokens: OAuthToken | None = None
self._client_info: OAuthClientInformationFull | None = None
async def get_tokens(self) -> OAuthToken | None: # pragma: no cover
async def get_tokens(self) -> OAuthToken | None:
return self._tokens
async def set_tokens(self, tokens: OAuthToken) -> None: # pragma: no cover

View file

@ -40,7 +40,7 @@ class StreamSpyCollection:
self.client.sent_messages.clear()
self.server.sent_messages.clear()
def get_client_requests(self, method: str | None = None) -> list[JSONRPCRequest]: # pragma: no cover
def get_client_requests(self, method: str | None = None) -> list[JSONRPCRequest]:
"""Get client-sent requests, optionally filtered by method."""
return [
req.message

View file

@ -1696,7 +1696,7 @@ class TestSEP985Discovery:
final_response = httpx.Response(200, request=final_request)
try:
await auth_flow.asend(final_response)
except StopAsyncIteration: # pragma: no cover
except StopAsyncIteration:
pass
@pytest.mark.anyio

View file

@ -94,7 +94,7 @@ def non_sdk_server(non_sdk_server_port: int) -> Generator[None, None, None]:
proc.start()
# Wait for server to be ready
try: # pragma: no cover
try:
wait_for_server(non_sdk_server_port, timeout=10.0)
except TimeoutError: # pragma: no cover
proc.kill()

View file

@ -157,7 +157,7 @@ async def test_stdio_client_universal_cleanup():
@pytest.mark.anyio
@pytest.mark.skipif(sys.platform == "win32", reason="Windows signal handling is different")
async def test_stdio_client_sigint_only_process(): # pragma: no cover
async def test_stdio_client_sigint_only_process(): # pragma: lax no cover
"""Test cleanup with a process that ignores SIGTERM but responds to SIGINT."""
# Create a Python script that ignores SIGTERM but handles SIGINT
script_content = textwrap.dedent(
@ -481,7 +481,7 @@ class TestChildProcessCleanup:
await anyio.sleep(0.5)
# Verify child is writing
if os.path.exists(marker_file): # pragma: no cover
if os.path.exists(marker_file): # pragma: no branch
size1 = os.path.getsize(marker_file)
await anyio.sleep(0.3)
size2 = os.path.getsize(marker_file)

View file

@ -34,10 +34,8 @@ def fastmcp_server() -> FastMCP:
"""Create a FastMCP server for testing."""
server = FastMCP("test")
# pragma: no cover on handlers below - they exist only to register capabilities.
# Transport tests verify stream creation and basic protocol, not handler invocation.
@server.tool()
def greet(name: str) -> str: # pragma: no cover
def greet(name: str) -> str:
"""Greet someone by name."""
return f"Hello, {name}!"