From eb3e297db1039759092f5ba7a7907af6ec3b8e91 Mon Sep 17 00:00:00 2001 From: Lawrence Babb Date: Wed, 30 Sep 2026 17:54:24 +0800 Subject: [PATCH] refactor: document CCV classification and look up method type by value Two cleanups from the #78 review (the duplicate proposition union was already fixed on this branch by "fix dup"): - ccv: give VariantOncogenicityStatement.classification a description so its Field(...) documents the field like every sibling. - validators: resolve the method type by enum VALUE (cls.MethodType(method_type)) instead of by mangled member NAME (cls.MethodType[method_type.upper()]). The name-based lookup only worked because every value equals its lowercased member name; methodType holds the value, so look it up by value. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/ga4gh/va_spec/base/validators.py | 4 ++-- src/ga4gh/va_spec/ccv_2022/models.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ga4gh/va_spec/base/validators.py b/src/ga4gh/va_spec/base/validators.py index 8e18ec5..997e8bd 100644 --- a/src/ga4gh/va_spec/base/validators.py +++ b/src/ga4gh/va_spec/base/validators.py @@ -127,8 +127,8 @@ def _validate_method_type_evidence_outcome( not valid for the specified method type, or if method type is invalid """ try: - parsed_method_type = cls.MethodType[method_type.upper()] - except KeyError as e: + parsed_method_type = cls.MethodType(method_type) + except ValueError as e: msg = f"{method_type!r} is not a valid {cls.__qualname__}.MethodType" raise ValueError(msg) from e allowed_criteria = cls.ALLOWED_CRITERIA_BY_METHOD_TYPE[parsed_method_type] diff --git a/src/ga4gh/va_spec/ccv_2022/models.py b/src/ga4gh/va_spec/ccv_2022/models.py index 86ed3f3..df3db3d 100644 --- a/src/ga4gh/va_spec/ccv_2022/models.py +++ b/src/ga4gh/va_spec/ccv_2022/models.py @@ -272,6 +272,7 @@ class VariantOncogenicityStatement(CCV2022MetadataMixin, Statement): ) classification: MappableConcept | iriReference = Field( ..., + description="A single term or phrase classifying the subject variant based on the result of direction and strength assessments of the Statement's Proposition, using terms from the ClinGen/CGC/VICC 2022 Guidelines for Oncogenicity.", ) specifiedBy: Method | iriReference = Field( ...,