Repository navigation
[TEST] pyOpenMS: accept short-form Sphinx cross-reference roles in the docstring RST check - #9805
Conversation
…e docstring RST check test_docstrings.py validates that every docstring is "compatible with Sphinx documentation generation", and its _is_acceptable_error() allowlist already filters the Sphinx constructs that the plain docutils parser cannot resolve: py:-prefixed roles and directives, the deprecated directive, and napoleon section headers. It did not cover the short, default-domain spelling of the same roles. Python is the default domain in a Python project, so :meth:`foo` is the idiomatic form and means exactly what :py:meth:`foo` means -- but only the latter was accepted. The FeatureFinderAlgorithmMetaboIdent addon uses the short form, so pyopenms_docstring_tests failed on develop with six Unknown interpreted text role "meth". The docstrings are correct; the allowlist was incomplete. Accept the Sphinx Python-domain and standard cross-reference roles in their short spelling too. The roles are listed explicitly rather than accepting any unknown role, so a misspelt one is still reported. Test-only change. pyopenms_docstring_tests goes from 2738 passed / 1 failed to 2739 passed; the unittest suite is unaffected at 2501 passed. Co-Authored-By: Claude Opus 5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughDocstring validation now accepts only whitelisted Sphinx cross-reference roles when filtering docutils errors. Other validation and RST parsing behavior remains unchanged. ChangesDocstring validation
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/pyOpenMS/tests/unittests/test_docstrings.py`:
- Around line 132-136: Update the role handling in test_docstrings.py so an
optional “py:” prefix is normalized before validating the role name against
_SPHINX_ROLES, rather than accepting every prefixed role. Preserve acceptance of
valid prefixed roles while rejecting misspellings such as py:methd, and add
regression coverage for both valid and invalid prefixed forms.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0f5ed328-b0b4-4261-abe2-824fe231dd13
📒 Files selected for processing (1)
src/pyOpenMS/tests/unittests/test_docstrings.py
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Audited recently merged develop PRs against CHANGELOG (last backfill attempt was #9811/#9806, covering up to #9803). Four merged PRs since then were missing entries: #9824 (IsobaricWorkflow empty-feature pruning fix), #9523 (new CI build/release workflows), #9812 (pyOpenMS docstring fixes) and #9798 (Bioconda nightly deploy fix, whose two prior backfill attempts were closed unmerged). #9821 (internal TODO-comment correction, no behavior/doc change) and #9805/#9803 (test-only / already covered by the #9792 write-up) were left out, consistent with this repo's convention of not logging test-infrastructure-only or already-documented changes. Claude-Session: https://claude.ai/code/session_01WU21QuzvxLH5BuSxatVikX Co-authored-by: Claude <[email protected]>
…9835, #9836 (#9841) Backfills the QPX export spec-conformance series, the macOS PKG notarization fix, and the Windows GUI DLL export fix that merged into develop without changelog entries. #9805 and #9821 were intentionally skipped (test-only / comment-only, no user-visible behavior change), and #9818 was already documented. Claude-Session: https://claude.ai/code/session_0118Yt3TZEMzhMhH6FwZPDVt Co-authored-by: Claude <[email protected]>
pyopenms_docstring_testsis currently red ondevelop, and has been since theFeatureFinderAlgorithmMetaboIdentaddon landed:The docstrings are fine — the allowlist was incomplete
test_docstrings.pyvalidates that docstrings are "compatible with Sphinx documentation generation", and it validates them with plain docutils, which does not know Sphinx's roles and directives._is_acceptable_error()already exists to paper over exactly that gap, and already filters:unknown interpreted text role "py:…"unknown directive type "py:…"unknown directive type "deprecated"unexpected section title(napoleon's NumPy-styleParameters/Returnsheaders)What it did not cover is the short, default-domain spelling of those same roles. Python is the default domain in a Python project, so
:meth:`foo`means exactly what:py:meth:`foo`means and is the idiomatic way to write it — but only thepy:-prefixed form was accepted.src/pyOpenMS/pyopenms/addons/featurefinderalgorithmmetaboident.pyuses the short form (6 occurrences, the only Sphinx roles anywhere in pyOpenMS docstring sources), so it tripped the check.The change
Accept the Sphinx Python-domain and standard cross-reference roles in their short spelling too. The roles are listed explicitly rather than accepting any unknown role, so a misspelt one is still reported — the check keeps its teeth:
Verification
pyopenms_docstring_testspyopenms_unittestsNegative controls, to confirm the check still catches real mistakes:
Unknown interpreted text role "meth"Unknown interpreted text role "py:meth"Unknown interpreted text role "ref"Unknown interpreted text role "mehtod"(typo)Unknown interpreted text role "bogus"Notes
:meth:cross-references as plain``literals — would degrade real Sphinx cross-links and leave the same trap for the next docstring that uses a short role.Summary by CodeRabbit