Skip to content

fix(enrichment): handle docstring-only stubs, multi-statement stubs, and deprecated abstract decorators#391

Merged
Alberto-Codes merged 3 commits intomainfrom
fix/enrichment-stub-abstract-detection
Mar 24, 2026
Merged

fix(enrichment): handle docstring-only stubs, multi-statement stubs, and deprecated abstract decorators#391
Alberto-Codes merged 3 commits intomainfrom
fix/enrichment-stub-abstract-detection

Conversation

@Alberto-Codes
Copy link
Copy Markdown
Owner

Three stub/abstract detection bugs caused false positives on Protocol methods and
legacy abstract decorators. Users running docvet on codebases with typing.Protocol
or deprecated abc decorators hit spurious extra-returns-in-docstring findings.

  • Recognize docstring-only function bodies as stubs in _is_stub_function
  • Accept multi-statement stub bodies via all(_is_stub_statement) instead of len == 1
  • Add _ABSTRACT_DECORATORS frozenset and _is_abstract() helper detecting all 4 abc decorators
  • Update _should_skip_reverse_check and _should_skip_returns_check to use _is_abstract
  • Add 28 tests covering all new paths (helpers, rule-level, orchestrator-level)

Test: uv run pytest tests/unit/checks/test_missing_returns.py tests/unit/checks/test_reverse_enrichment.py -v

Closes #387
Closes #388
Closes #389

chore(process): update sprint-status with story 32-3 done and refresh timestamp


PR Review

Checklist

  • Self-reviewed my code
  • Tests pass (uv run pytest)
  • Lint passes (uv run ruff check .)
  • Types pass (uv run ty check)
  • Breaking changes use ! in title and BREAKING CHANGE: in body

Review Focus

Related

…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
@Alberto-Codes Alberto-Codes marked this pull request as ready for review March 24, 2026 15:31
Copilot AI review requested due to automatic review settings March 24, 2026 15:31
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_function to treat docstring-only bodies as stubs and allow multi-statement stub bodies via all(_is_stub_statement).
  • Add _ABSTRACT_DECORATORS and _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.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@Alberto-Codes Alberto-Codes merged commit bc2445d into main Mar 24, 2026
16 checks passed
@Alberto-Codes Alberto-Codes deleted the fix/enrichment-stub-abstract-detection branch March 24, 2026 15:51
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants