Skip to content

refactor(enrichment): extract params, deprecation, reverse, late rules - #382

Merged
Alberto-Codes merged 2 commits into
mainfrom
refactor/enrichment-batch-extraction
Mar 23, 2026
Merged

Alberto-Codes merged 2 commits into
mainfrom
refactor/enrichment-batch-extraction

Conversation

@Alberto-Codes

Copy link
Copy Markdown
Owner

enrichment/__init__.py was 1,435 lines after the class/module extraction (#381). This batch extracts the 4 remaining concerns into dedicated submodules, bringing the orchestrator under the 500-line gate.

  • Extract param agreement checks to _params.py (315 lines)
  • Extract deprecation notice checks to _deprecation.py (206 lines)
  • Extract reverse checks (extra raises/yields/returns) to _reverse.py (209 lines)
  • Extract late rules (trivial docstring, return type, init params) to _late_rules.py (375 lines)
  • Reduce __init__.py from 1,435 to 466 lines (now under 500-line gate)
  • Submodules access _active_style via import docvet.checks.enrichment as _enrichment_pkg at runtime

Test: uv run pytest (1,660 tests, zero modifications)

Closes #369, closes #370, closes #371, closes #372


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

  • _active_style access pattern: submodules use import docvet.checks.enrichment as _enrichment_pkg then _enrichment_pkg._active_style at call time — no circular import since the module is fully initialized before any check function is called
  • _reverse.py imports _parse_raises_entries from _params.py (cross-submodule dependency) and _should_skip_reverse_check from parent __init__.py
  • _late_rules.py imports _find_init_method from _class_module.py and _parse_sections from parent

Related

Batch extract 4 remaining enrichment concerns into dedicated submodules:
- _params.py: parameter agreement checks (315 lines)
- _deprecation.py: missing deprecation notice checks (206 lines)
- _reverse.py: extra raises/yields/returns checks (209 lines)
- _late_rules.py: trivial docstring, return type, init params (375 lines)

Reduces enrichment/__init__.py from 1,435 to 466 lines — now under the
500-line module size gate. Submodules access _active_style via the parent
package module object at runtime.

Closes #369, closes #370, closes #371, closes #372
@codecov

codecov Bot commented Mar 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.39776% with 20 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/docvet/checks/enrichment/_params.py 94.82% 6 Missing ⚠️
src/docvet/checks/enrichment/_deprecation.py 90.90% 5 Missing ⚠️
src/docvet/checks/enrichment/_reverse.py 93.58% 5 Missing ⚠️
src/docvet/checks/enrichment/_late_rules.py 96.11% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Alberto-Codes
Alberto-Codes marked this pull request as ready for review March 23, 2026 20:19
Copilot AI review requested due to automatic review settings March 23, 2026 20:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Refactors the enrichment check package by extracting the remaining rule groups into dedicated submodules, keeping checks/enrichment/__init__.py focused on orchestration/dispatch and under the repo’s 500-line gate.

Changes:

  • Extract parameter agreement checks/helpers into _params.py.
  • Extract deprecation detection/check into _deprecation.py.
  • Extract reverse checks (extra Raises/Yields/Returns) into _reverse.py.
  • Extract late-added rules (trivial docstring, missing return type, undocumented init params) into _late_rules.py, and wire all into the dispatcher via __init__.py.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/docvet/checks/enrichment/__init__.py Removes inlined rule implementations and re-wires dispatch/imports to the new submodules while retaining parsing + orchestrator.
src/docvet/checks/enrichment/_params.py New module for signature/docstring parameter agreement parsing and checks.
src/docvet/checks/enrichment/_deprecation.py New module for deprecation pattern detection and the “missing deprecation notice” check.
src/docvet/checks/enrichment/_reverse.py New module for reverse checks that validate docstring claims against AST behavior.
src/docvet/checks/enrichment/_late_rules.py New module for trivial-docstring, missing-return-type, and undocumented-init-params rules.

Comment thread src/docvet/checks/enrichment/__init__.py Outdated
Drop module_display_name from __init__.py imports — only used by
submodules which import it directly. Removes blanket noqa: F401 that
was masking the unused import.
@Alberto-Codes
Alberto-Codes merged commit c18e807 into main Mar 23, 2026
12 checks passed
@Alberto-Codes
Alberto-Codes deleted the refactor/enrichment-batch-extraction branch March 23, 2026 20:48
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