Skip to content

refactor(enrichment): extract class/module checks to _class_module.py - #381

Merged
Alberto-Codes merged 1 commit into
mainfrom
refactor/enrichment-class-module-extraction
Mar 23, 2026
Merged

Alberto-Codes merged 1 commit into
mainfrom
refactor/enrichment-class-module-extraction

Conversation

@Alberto-Codes

Copy link
Copy Markdown
Owner

enrichment/__init__.py was 2,259 lines — 4.5x the 500-line module size gate. The class/module check block was the largest self-contained concern at ~824 lines. This continues the enrichment sub-package extraction series started in #377.

  • Extract 6 check functions + 11 helpers + 5 constants to _class_module.py
  • Add deferred import block re-exporting 14 symbols for test and orchestrator access
  • Reduce __init__.py from 2,259 to 1,450 lines (36% reduction)
  • Update module docstring to reflect sub-package structure

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

Closes #368


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

  • Deferred import block (14 symbols) — correct re-export list for tests
  • Relative imports from parent (_extract_section_content, _SEE_ALSO, _XREF_MD_LINK, _XREF_SPHINX) — ordering-dependent, works because all defined before deferred import line
  • _find_init_method cross-consumed by _check_undocumented_init_params (stays in __init__.py)

Related

Extract 6 check functions, 11 helpers, and 5 constants (missing-attributes,
missing-typed-attributes, missing-examples, missing-cross-references,
prefer-fenced-code-blocks) into enrichment/_class_module.py. Deferred
import block re-exports 14 symbols for test and orchestrator access.

- Reduce enrichment/__init__.py from 2,259 to 1,450 lines (36% reduction)
- New _class_module.py at 857 lines with class/module enrichment checks
- Update module docstring to reflect sub-package structure
- Zero external API changes, zero test modifications

Closes #368
@codecov

codecov Bot commented Mar 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.00000% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/docvet/checks/enrichment/_class_module.py 94.97% 11 Missing ⚠️

📢 Thoughts on this report? Let us know!

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

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

This PR continues the enrichment refactor by extracting the class/module-focused enrichment rules out of checks/enrichment/__init__.py into a dedicated submodule, reducing the size and responsibility of the package initializer while preserving the existing external import surface via re-exports.

Changes:

  • Added src/docvet/checks/enrichment/_class_module.py containing the class/module checks, helpers, and related constants.
  • Removed the extracted block from src/docvet/checks/enrichment/__init__.py and added a deferred import re-export block for compatibility.
  • Updated the __init__.py module docstring to describe the new submodule organization.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/docvet/checks/enrichment/_class_module.py New extracted module for class/module enrichment checks and helpers.
src/docvet/checks/enrichment/__init__.py Removes extracted implementations; adds deferred imports/re-exports and updates module docstring.

Comment thread src/docvet/checks/enrichment/_class_module.py
Comment thread src/docvet/checks/enrichment/_class_module.py
@Alberto-Codes
Alberto-Codes merged commit a79f487 into main Mar 23, 2026
16 checks passed
@Alberto-Codes
Alberto-Codes deleted the refactor/enrichment-class-module-extraction branch March 23, 2026 19:43
Alberto-Codes added a commit that referenced this pull request Mar 23, 2026
#382)

`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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(enrichment): extract class/module checks to _class_module.py

2 participants