Skip to content

Commit 12f8beb

Browse files
committed
fix: make strict-no-cover functional and add test pragma
Two issues prevented strict-no-cover from detecting unnecessary pragmas: 1. Coverage 7.13.x changed analysis_from_file_reporter to filter executed lines with '& statements', which removes excluded lines from the executed set. This breaks strict-no-cover's detection (it checks the intersection of excluded_lines and executed_lines). Pin to <7.13. 2. relative_files = true causes coverage to store relative paths, but strict-no-cover creates a temp rcfile without [tool.coverage.run] settings. Without relative_files in that temp config, coverage can't match paths, resulting in empty executed_lines. Also adds a test pragma on a covered line to verify the check fails.
1 parent d078fcd commit 12f8beb

File tree

3 files changed

+98
-99
lines changed

3 files changed

+98
-99
lines changed

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ dev = [
6767
"pytest-pretty>=1.2.0",
6868
"inline-snapshot>=0.23.0",
6969
"dirty-equals>=0.9.0",
70-
"coverage[toml]>=7.13.1",
70+
"coverage[toml]>=7.10.7,<7.13",
7171
"pillow>=12.0",
7272
"strict-no-cover",
7373
]
@@ -201,7 +201,6 @@ branch = true
201201
patch = ["subprocess"]
202202
concurrency = ["multiprocessing", "thread"]
203203
source = ["src", "tests"]
204-
relative_files = true
205204
omit = [
206205
"src/mcp/client/__main__.py",
207206
"src/mcp/server/__main__.py",

src/mcp/shared/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class McpError(Exception):
1313
def __init__(self, error: ErrorData):
1414
"""Initialize McpError."""
1515
super().__init__(error.message)
16-
self.error = error
16+
self.error = error # pragma: no cover
1717

1818

1919
class StatelessModeNotSupported(RuntimeError):

0 commit comments

Comments
 (0)