refactor: split enumerator.py into a subpackage (#197) - #265
Open
iabaako wants to merge 3 commits into
Open
Conversation
Splits the 2,674-line checks/enumerator.py into models/compute/ settings_ui/report_ui submodules so it's easier to navigate and review. The public entry points (enumerator_report, enumerator_report_settings) stay importable from datasure.checks.enumerator unchanged. Tests are mirrored into tests/checks/enumerator/ with no logic changes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…e __init__ Every other package __init__.py in this repo is empty; re-exporting symbols there hides which submodule actually defines them. Import enumerator_report directly from checks.enumerator.report_ui instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…r module Sonar flagged code duplication above the 3% threshold in compute.py (10.4%) and settings_ui.py (3.6%). Extracts the shared "TIME PERIOD" column logic used by both productivity and statistics-overtime computation into _add_time_period_column, and the repeated selectbox/save patterns in the settings UI into _render_column_select and _render_category_settings. No behavior change. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
This was referenced Aug 7, 2026
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.



Pull Request Summary 🚀
What does this PR do? 📝
Splits
src/datasure/checks/enumerator.py(2,674 lines) into a subpackage,src/datasure/checks/enumerator/:models.py— Pydantic settings/result models and module constantscompute.py— purecompute_*data-processing functions (no Streamlit calls)settings_ui.py—enumerator_report_settingsand its config-UI helpersreport_ui.py—enumerator_reportand its report-rendering UI helpers__init__.py— re-exportsenumerator_reportandenumerator_report_settingsTests are mirrored into
tests/checks/enumerator/{conftest,test_models,test_compute,test_settings_ui,test_report_ui}.py, replacing the 1,921-linetests/checks/test_enumerator.py.This is the first of four planned splits tracked by #197 (enumerator → gpschecks → outliers → backchecks, smallest to largest), closing out the enumerator portion of that issue.
Why is this change needed? 🤔
Per #197: the largest check modules are hard to navigate and review.
enumerator.pymixed settings models, pure computation, and two distinct Streamlit UI flows (settings vs. report) in one file, making it hard to find or safely change any one piece.How was this implemented? 🛠️
Pure mechanical reorganization — no logic changes. I confirmed by grepping the full
src/tree that onlyenumerator_reportis imported outside this module (byoutput_view_template.pyand generatedoutput_view_N.pyfiles), so__init__.pyre-exports it (andenumerator_report_settings, for symmetry) to keepfrom datasure.checks.enumerator import enumerator_reportworking with zero changes needed elsewhere. All other functions were module-private and could move freely.One test needed retargeting:
enumerator_report_settings(now insettings_ui.py) calls_render_consent_outcome_settings(now inreport_ui.py) — a test that patched that function on the single original module now patches it onsettings_uidirectly instead. Same test intent, just pointed at the module that now owns the function.How to test or reproduce ? 🧪
uv run python -m pytest tests/checks/enumerator --cov=datasure.checks.enumerator --cov-report=term-missing -q— 116 tests pass, 99.86% coverage (identical to pre-split numbers)uv run python -m pytest -q -m "not slow"— full suite passes, same pre-existing skipsScreenshots (if applicable) 📷
N/A — no UI or behavior changes.
Checklist ✅
🤖 Generated with Claude Code