Remove duplicate implementations in the classification app #1796 - #1798
Open
davmlaw wants to merge 1 commit into
Open
Remove duplicate implementations in the classification app #1796#1798davmlaw wants to merge 1 commit into
davmlaw wants to merge 1 commit into
Conversation
- delete evidence_key_cleaner: an identical copy of unknown_evidence_key_cleaner, whose only extra argument was never read and made argparse raise at add_argument - delete Classification.get_allele_info_dict: dead since classification_json took over, and had missed the g.HGVS fallback (#1063) and variant_coordinate since - pull the met-criteria + AMP level walk up into EvidenceMixin.met_criteria_strengths - share the discordance movement guards between _less_more_certain and _up_down_for
davmlaw
force-pushed
the
issue_1796_classification_duplicate_code
branch
from
August 31, 2026 00:09
b6013b8 to
e1d23cd
Compare
This was referenced Aug 31, 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.
🤖 Written by Claude
Addresses #1796 — duplicated implementations in the
classificationapp, found by a token-normalised clone scan plus AST structural-similarity pass over the codebase.Two deletions and two extractions. Net -111 lines.
Deletions
classification/management/commands/evidence_key_cleaner.py— identical tounknown_evidence_key_cleaner.pyapart from a--keyargument thathandle()never read and that made argparse raiseValueError: 'str' is not callableatadd_argumenttime (type='str', the string rather than the builtin). The command could not run at all, including--help, and nothing referenced it.unknown_evidence_key_cleaneris unchanged and still registered.Classification.get_allele_info_dict()— no callers anywhere;classification_json.get_allele_info_dict()is what actually runs, viapopulate_classification_json. The dead copy had already drifted: it never picked up theimported_g_hgvs_objfallback added by #1063, norVARIANT_COORDINATEin the per-build dict.Extractions
EvidenceMixin.met_criteria_strengths()—classification_groups.acmg_criteriaandClassificationSummaryCalculator.criteria_labelseach had their own copy of the same walk (met criteria fromEvidenceKeyMap.cached().criteria(), thenAMP_LEVELS_TO_LEVELexpanded into custom-strengthCriteriaStrengths). Both call sites hold aClassificationModification, which is anEvidenceMixin, so the walk now lives on the mixin and each caller keeps only its own output shaping. Behaviour is unchanged — the one difference is that the AMP branch reuses thee_keyit already looked up instead of callingEvidenceKeyMap.cached_key(amp_level)a second time for the same key.DiscordanceReportAdminExport._describe_movement()—_less_more_certainand_up_down_forshared a seven-line prelude and thewithdrawn/same/?guards. Those now live in one place, and each caller passes just the comparison that distinguishes it.Left out
The near-identical context dicts in
classificationsandclassification_groupings(classification/views/views.py) are untouched — #1765 proposes deleting the deadclassification_groupingspage outright, which removes that duplication properly.The
_variant_ids_by_gene/_zipf_weightpair shared withanalysis/fake_variant_tags.pyhas moved out of this PR, and is handled with the rest of the cross-app duplication instead.Testing
manage.py test --keepdb classification— 139 tests, OKmanage.py test --keepdb analysis annotation snpdb— 1168 tests, OKmanage.py checkclean;ruffreports no new findings on any changed fileevidence_key_cleaneris gone frommanage.py help, whileunknown_evidence_key_cleanerremains🤖 Generated with Claude Code
https://claude.ai/code/session_01TKZV4Gh7ZXRjqx7ibPDTSd