From b1b4e548c85e3cfb9a0b3af7335874740aed1515 Mon Sep 17 00:00:00 2001 From: Alex Kanitz Date: Tue, 31 May 2022 22:11:47 -0600 Subject: [PATCH] fix: pydantic validation of None in enums --- htsinfer/get_read_orientation.py | 1 + htsinfer/models.py | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/htsinfer/get_read_orientation.py b/htsinfer/get_read_orientation.py index 1de49a13..b6f25688 100644 --- a/htsinfer/get_read_orientation.py +++ b/htsinfer/get_read_orientation.py @@ -585,6 +585,7 @@ def process_paired( # pylint: disable=R0912,R0915 if reads >= self.min_mapped_reads: if fraction_most_common_state > self.min_fraction: orientation.relationship = most_common_state + assert orientation.relationship is not None if orientation.relationship.value[-2:] == "SF": orientation.file_1 = StatesOrientation("SF") orientation.file_2 = StatesOrientation("SR") diff --git a/htsinfer/models.py b/htsinfer/models.py index 96bdada3..b70176e7 100644 --- a/htsinfer/models.py +++ b/htsinfer/models.py @@ -182,9 +182,9 @@ class ResultsType(BaseModel): file_2: Library type of the second file. relationship: Type/mate relationship between the provided files. """ - file_1: StatesType = StatesType.not_available - file_2: StatesType = StatesType.not_available - relationship: StatesTypeRelationship = ( + file_1: Optional[StatesType] = StatesType.not_available + file_2: Optional[StatesType] = StatesType.not_available + relationship: Optional[StatesTypeRelationship] = ( StatesTypeRelationship.not_available ) @@ -270,9 +270,9 @@ class ResultsOrientation(BaseModel): file_1: Read orientation of first file. file_2: Read orientation of second file. """ - file_1: StatesOrientation = StatesOrientation.not_available - file_2: StatesOrientation = StatesOrientation.not_available - relationship: StatesOrientationRelationship = ( + file_1: Optional[StatesOrientation] = StatesOrientation.not_available + file_2: Optional[StatesOrientation] = StatesOrientation.not_available + relationship: Optional[StatesOrientationRelationship] = ( StatesOrientationRelationship.not_available )