Skip to content

Commit 7165b99

Browse files
rustyconoverclaude
andcommitted
test(docstrings): skip pydoclint gate when its env is broken
pydoclint depends on docstring-parser-fork while vgi-rpc depends on the upstream docstring-parser; both own the `docstring_parser` import namespace, so on some interpreter/OS combinations (seen on 3.14 + Windows) pydoclint crashes on import. Distinguish that "tool failed to run" case (skip) from real docstring violations (fail), so a broken tool env doesn't red CI while the gate still runs on healthy matrix cells. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4140efe commit 7165b99

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

tests/test_docstrings.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
test invokes the same CLI, so there is no duplicated rule set.
1111
"""
1212

13+
import re
1314
import shutil
1415
import subprocess
1516
from pathlib import Path
@@ -18,6 +19,11 @@
1819

1920
_REPO_ROOT = Path(__file__).resolve().parents[1]
2021

22+
# A real violation line looks like `` 42: DOC101: ...``. If pydoclint exits
23+
# non-zero without emitting any such code, it failed to *run* (e.g. import
24+
# error) rather than finding violations — see the environment note below.
25+
_VIOLATION_RE = re.compile(r"\bDOC\d{3}\b")
26+
2127

2228
def test_pydoclint_clean() -> None:
2329
"""``vgi/`` must pass the pydoclint docstring gate (config in pyproject.toml)."""
@@ -31,10 +37,23 @@ def test_pydoclint_clean() -> None:
3137
capture_output=True,
3238
text=True,
3339
)
40+
output = result.stdout + result.stderr
41+
42+
if result.returncode == 0:
43+
return
44+
45+
# pydoclint depends on ``docstring-parser-fork`` while ``vgi-rpc`` depends on
46+
# the upstream ``docstring-parser``; both claim the ``docstring_parser``
47+
# import namespace, so on some interpreter/OS combinations the wrong files
48+
# win and pydoclint crashes on import. That's a broken tool environment, not
49+
# a docstring problem — skip rather than fail (the gate still runs on every
50+
# other matrix cell where the tool is healthy).
51+
if not _VIOLATION_RE.search(output): # pragma: no cover - env-dependent
52+
pytest.skip(f"pydoclint could not run in this environment:\n{output}")
3453

35-
assert result.returncode == 0, (
54+
pytest.fail(
3655
"pydoclint found docstring violations:\n\n"
37-
f"{result.stdout}{result.stderr}\n"
56+
f"{output}\n"
3857
"Fix the docstrings, or run "
3958
"`uv run pydoclint --generate-baseline=True --baseline=.pydoclint-baseline vgi/` "
4059
"to defer them (see [tool.pydoclint] in pyproject.toml)."

0 commit comments

Comments
 (0)