fix(enrichment): handle docstring-only stubs, multi-statement stubs, and deprecated abstract decorators#391
Merged
Alberto-Codes merged 3 commits intomainfrom Mar 24, 2026
Conversation
…and deprecated abstract decorators Fix three stub/abstract detection bugs that caused false positives on Protocol methods and legacy abstract decorators: - Recognize docstring-only function bodies as stubs (#387) - Accept multi-statement stub bodies via all() check (#388) - Detect @abstractclassmethod, @abstractstaticmethod, @abstractproperty (#389) Closes #387 Closes #388 Closes #389
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Fixes enrichment false-positives by broadening “stub function” detection (docstring-only bodies and multi-statement stub bodies) and by recognizing deprecated abc abstract decorators when deciding whether to skip reverse enrichment checks.
Changes:
- Update
_is_stub_functionto treat docstring-only bodies as stubs and allow multi-statement stub bodies viaall(_is_stub_statement). - Add
_ABSTRACT_DECORATORSand_is_abstract()and use them in reverse-check skip logic and missing-returns skip logic. - Add/extend unit tests for the new stub/abstract detection paths; update sprint-status metadata.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/docvet/checks/enrichment/_forward.py |
Adds _is_abstract / _is_stub_statement and broadens stub detection; uses abstract detection in returns-skip guard. |
src/docvet/checks/enrichment/__init__.py |
Re-exports new helpers and updates _should_skip_reverse_check to use _is_abstract. |
tests/unit/checks/test_missing_returns.py |
Adds helper-level and orchestrator-level tests for stub/abstract behavior (needs a small adjustment per comments). |
tests/unit/checks/test_reverse_enrichment.py |
Adds tests for docstring-only stubs and deprecated abstract decorators (some tests currently pass even without the #389 fix due to stubs). |
_bmad-output/implementation-artifacts/sprint-status.yaml |
Updates generated timestamp and story status. |
… _is_abstract path Address Copilot review: tests for deprecated abstract decorators used stub bodies (...) that would pass via _is_stub_function even if _is_abstract were broken. Replace with non-stub bodies so the only skip reason is the abstract decorator.
Alberto-Codes
added a commit
that referenced
this pull request
Mar 27, 2026
🤖 I have created a release *beep* *boop* --- ## [1.15.0](v1.14.1...v1.15.0) (2026-03-27) ### Features * **cli:** add docvet fix subcommand with dry-run and discovery ([#386](#386)) ([7f76477](7f76477)) * **cli:** add inline suppression comments for findings ([#393](#393)) ([14ba0b7](14ba0b7)) * **enrichment:** add scaffold category, scaffolding engine, and scaffold-incomplete rule ([#385](#385)) ([782cd27](782cd27)) * **enrichment:** add scaffold-incomplete enrichment rule ([782cd27](782cd27)) ### Bug Fixes * **cli:** address code review findings for fix subcommand ([7f76477](7f76477)) * **cli:** prevent uppercase rule IDs from degrading to blanket ([14ba0b7](14ba0b7)) * **config:** address PR [#379](#379) review feedback ([#380](#380)) ([134e428](134e428)) * **enrichment:** handle docstring-only stubs, multi-statement stubs, and deprecated abstract decorators ([#391](#391)) ([bc2445d](bc2445d)), closes [#387](#387) [#388](#388) [#389](#389) * **griffe:** replace production assert, fix dep vulns, add vuln handling docs ([#395](#395)) ([7273e56](7273e56)) * **test:** move _active_style reset to shared conftest fixture ([#363](#363)) ([b8b6586](b8b6586)) ### Documentation * **cli:** add missing subcommands to quick references ([#397](#397)) ([d92af72](d92af72)), closes [#396](#396) * **enrichment:** add scaffold-incomplete rule page and config docs ([782cd27](782cd27)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three stub/abstract detection bugs caused false positives on Protocol methods and
legacy abstract decorators. Users running docvet on codebases with
typing.Protocolor deprecated
abcdecorators hit spuriousextra-returns-in-docstringfindings._is_stub_functionall(_is_stub_statement)instead oflen == 1_ABSTRACT_DECORATORSfrozenset and_is_abstract()helper detecting all 4 abc decorators_should_skip_reverse_checkand_should_skip_returns_checkto use_is_abstractTest:
uv run pytest tests/unit/checks/test_missing_returns.py tests/unit/checks/test_reverse_enrichment.py -vCloses #387
Closes #388
Closes #389
chore(process): update sprint-status with story 32-3 done and refresh timestamp
PR Review
Checklist
uv run pytest)uv run ruff check .)uv run ty check)!in title andBREAKING CHANGE:in bodyReview Focus
_is_stub_statementalignment with ruff'sis_stub()— confirmed via source atfunction_type.rs_is_abstractalignment with ruff'sis_abstract()— confirmed via source atvisibility.rsraise NotImplemented(without Error) not handled — tracked in Enhancement: audit all enrichment rules against authoritative sources #390Related