refactor: split backchecks.py into a subpackage (#197) - #266
Open
iabaako wants to merge 1 commit into
Open
Conversation
Splits the 4,252-line checks/backchecks.py into models/compute/ settings_ui/report_ui submodules, mirroring the enumerator split. __init__.py stays empty per convention; output_view_template.py now imports backchecks_report directly from datasure.checks.backchecks.report_ui. Also eliminates two intra-file duplicates found while splitting: _render_no_differences_settings/_render_exclude_values_settings share a new _render_value_list_editor, and _add_extra_survey_columns/ _add_extra_backcheck_columns share a new _join_extra_columns. No behavior change. Tests mirrored into tests/checks/backchecks/ with no logic changes; 220/220 tests pass, coverage improved from 89.95% to 91.34%. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
This was referenced Aug 7, 2026
| sys.modules["streamlit"] = mock_st | ||
|
|
||
| import datasure.checks.backchecks.compute as compute_module | ||
| import datasure.checks.backchecks.report_ui as report_ui_module |
| sys.modules["streamlit"] = mock_st | ||
|
|
||
| import datasure.checks.backchecks.compute as compute_module | ||
| import datasure.checks.backchecks.settings_ui as settings_ui_module |
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/backchecks.py(4,252 lines) into a subpackage,src/datasure/checks/backchecks/:models.py— Pydantic settings/result models,StrEnums, and module constantscompute.py— purecompute_*/_calculate_*/_add_*_columnsdata-processing functions (no Streamlit calls)settings_ui.py—backchecks_report_settingsand its config-UI helpersreport_ui.py—backchecks_reportand its report-rendering UI helpers (including the backcheck-column-configuration UI, which turned out to be called only from the report entry point, not settings)__init__.py— left empty, matching every other package in this repoAlso eliminates two intra-file duplicates found while splitting:
_render_no_differences_settings/_render_exclude_values_settingsshared an identical add/remove-popover list-editor pattern → extracted_render_value_list_editor, with aguard_remove_membershipflag preserving the one subtle behavioral difference between the two callers_add_extra_survey_columns/_add_extra_backcheck_columnsshared a select→rename→suffix→join pattern → extracted_join_extra_columnsTests are mirrored into
tests/checks/backchecks/{conftest,test_models,test_compute,test_settings_ui,test_report_ui}.py, replacing the 4,303-linetests/checks/test_backchecks.py.This is the second of four planned splits tracked by #197 (enumerator done in #265, gpschecks/outliers still pending), stacked on top of
refactor/197-split-enumerator-modulesince that PR is still open.Why is this change needed? 🤔
Per #197:
backchecks.pywas the largest and hardest-to-review check module. It mixed settings models, pure computation, and two distinct Streamlit UI flows (settings vs. report) in one 4,252-line file.How was this implemented? 🛠️
Pure mechanical reorganization — no logic changes, aside from the two documented deduplications above (both verified to produce identical output via the existing test suite). Grepped the full
src/tree to confirm onlyoutput_view_template.pyimports from this module externally, and updated it to importbackchecks_reportdirectly fromdatasure.checks.backchecks.report_uiinstead of relying on package re-exports. The generated, gitignoredoutput_view_1.pywas left untouched, per this repo's convention of never editing generated output views directly — it's regenerated from the template.How to test or reproduce ? 🧪
uv run python -m pytest tests/checks/backchecks --cov=datasure.checks.backchecks --cov-report=term-missing -q— 220/220 tests pass (exact match to the pre-split count), coverage improved from 89.95% to 91.34%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