Skip to content

Commit edefce3

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 7080fcf commit edefce3

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
@@ -67,6 +67,7 @@ dev = [
6767
"dirty-equals>=0.9.0",
6868
"coverage[toml]>=7.13.1",
6969
"pillow>=12.0",
70+
"strict-no-cover",
7071
]
7172
docs = [
7273
"mkdocs>=1.6.1",
@@ -154,6 +155,7 @@ members = ["examples/clients/*", "examples/servers/*", "examples/snippets"]
154155

155156
[tool.uv.sources]
156157
mcp = { workspace = true }
158+
strict-no-cover = { git = "https://github.com/pydantic/strict-no-cover" }
157159

158160
[tool.pytest.ini_options]
159161
log_cli = true
@@ -207,6 +209,7 @@ ignore_errors = true
207209
precision = 2
208210
exclude_lines = [
209211
"pragma: no cover",
212+
"pragma: lax no cover",
210213
"if TYPE_CHECKING:",
211214
"@overload",
212215
"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)