Skip to content

Commit d078fcd

Browse files
committed
ci: add strict-no-cover to detect unnecessary coverage pragmas
Add strict-no-cover from pydantic to CI pipeline. This tool identifies `# pragma: no cover` comments on lines that are actually covered by tests, helping keep coverage pragmas accurate. Changes: - Add strict-no-cover as dev dependency (installed from git) - Add `pragma: lax no cover` to coverage exclude_lines for partial coverage - Add CI step to run strict-no-cover after coverage report (Linux only due to Windows bug in the tool)
1 parent f0ab53e commit d078fcd

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

.github/workflows/shared.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ jobs:
6262
uv run --frozen --no-sync coverage combine
6363
uv run --frozen --no-sync coverage report
6464
65+
- name: Check for unnecessary no cover pragmas
66+
if: runner.os != 'Windows'
67+
run: uv run --frozen --no-sync strict-no-cover
68+
6569
readme-snippets:
6670
runs-on: ubuntu-latest
6771
steps:

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ dev = [
6969
"dirty-equals>=0.9.0",
7070
"coverage[toml]>=7.13.1",
7171
"pillow>=12.0",
72+
"strict-no-cover",
7273
]
7374
docs = [
7475
"mkdocs>=1.6.1",
@@ -164,6 +165,7 @@ members = ["examples/clients/*", "examples/servers/*", "examples/snippets"]
164165

165166
[tool.uv.sources]
166167
mcp = { workspace = true }
168+
strict-no-cover = { git = "https://github.com/pydantic/strict-no-cover" }
167169

168170
[tool.pytest.ini_options]
169171
log_cli = true
@@ -216,6 +218,7 @@ ignore_errors = true
216218
precision = 2
217219
exclude_lines = [
218220
"pragma: no cover",
221+
"pragma: lax no cover",
219222
"if TYPE_CHECKING:",
220223
"@overload",
221224
"raise NotImplementedError",

uv.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)