Skip to content

Commit

Permalink
Fix enums (#2636)(patch)
Browse files Browse the repository at this point in the history
Due to a breaking change in Python 3.11 with string enums, some enum fields were not displayed correctly.
  • Loading branch information
seallard authored Oct 27, 2023
1 parent e84d8db commit 0d4d035
Show file tree
Hide file tree
Showing 22 changed files with 42 additions and 45 deletions.
2 changes: 1 addition & 1 deletion cg/constants/archiving.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from cg.utils.enums import StrEnum
from enum import StrEnum


class ArchiveLocations(StrEnum):
Expand Down
2 changes: 1 addition & 1 deletion cg/constants/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import click

from cg.utils.date import get_date
from cg.utils.enums import StrEnum
from enum import StrEnum

VALID_DATA_IN_PRODUCTION = get_date("2017-09-27")

Expand Down
2 changes: 1 addition & 1 deletion cg/constants/demultiplexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import click

from cg.constants.sequencing import Sequencers
from cg.utils.enums import Enum, StrEnum
from enum import Enum, StrEnum


class BclConverter(StrEnum):
Expand Down
6 changes: 3 additions & 3 deletions cg/constants/encryption.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Constants specific for encryption"""
from enum import Enum
from enum import StrEnum

from cg.utils.enums import ListEnum


class CipherAlgorithm(str, Enum):
class CipherAlgorithm(StrEnum):
TRIPLE_DES: str = "3DES"
AES: str = "AES"
AES192: str = "AES192"
Expand All @@ -18,7 +18,7 @@ class CipherAlgorithm(str, Enum):
TWOFISH: str = "TWOFISH"


class EncryptionUserID(str, Enum):
class EncryptionUserID(StrEnum):
HASTA_USER_ID: str = '"Clinical Genomics"'


Expand Down
2 changes: 1 addition & 1 deletion cg/constants/gene_panel.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Gene panel specific constants."""


from cg.utils.enums import StrEnum
from enum import StrEnum

GENOME_BUILD_37 = "37"
GENOME_BUILD_38 = "GRCh38"
Expand Down
2 changes: 1 addition & 1 deletion cg/constants/housekeeper_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


from cg.constants.constants import Pipeline
from cg.utils.enums import StrEnum
from enum import StrEnum


class AlignmentFileTag(StrEnum):
Expand Down
2 changes: 1 addition & 1 deletion cg/constants/invoice.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from cg.utils.enums import StrEnum
from enum import StrEnum


class CustomerNames(StrEnum):
Expand Down
2 changes: 1 addition & 1 deletion cg/constants/lims.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# LIMS constants

from cg.utils.enums import StrEnum
from enum import StrEnum

YES_NO_LIMS_BOOLEANS = ["require_qc_ok", "tumour", "verified_organism"]

Expand Down
2 changes: 1 addition & 1 deletion cg/constants/nf_analysis.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Nf-tower related constants."""
from cg.utils.enums import StrEnum
from enum import StrEnum


class NfTowerStatus(StrEnum):
Expand Down
2 changes: 1 addition & 1 deletion cg/constants/observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from cg.constants.constants import Pipeline
from cg.constants.sequencing import SequencingMethod
from cg.utils.enums import StrEnum
from enum import StrEnum

LOQUSDB_ID = "_id"
LOQUSDB_SUPPORTED_PIPELINES = [Pipeline.MIP_DNA, Pipeline.BALSAMIC]
Expand Down
2 changes: 1 addition & 1 deletion cg/constants/orderforms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from cg.constants import ANALYSIS_SOURCES, METAGENOME_SOURCES
from cg.models.orders.order import OrderType
from cg.utils.enums import StrEnum
from enum import StrEnum

SEX_MAP = {"male": "M", "female": "F", "unknown": "unknown"}
REV_SEX_MAP = {value: key for key, value in SEX_MAP.items()}
Expand Down
3 changes: 2 additions & 1 deletion cg/constants/pdc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""PDC related constants"""
from cg.utils.enums import IntEnum, ListEnum
from enum import IntEnum
from cg.utils.enums import ListEnum


class DSMCParameters(ListEnum):
Expand Down
4 changes: 2 additions & 2 deletions cg/constants/pedigree.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from enum import Enum
from enum import StrEnum


class Pedigree(str, Enum):
class Pedigree(StrEnum):
FATHER = "father"
MOTHER = "mother"
CHILD = "child"
Expand Down
2 changes: 1 addition & 1 deletion cg/constants/priority.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Priority specific constants"""
from enum import IntEnum

from cg.utils.enums import StrEnum
from enum import StrEnum


class SlurmQos(StrEnum):
Expand Down
2 changes: 1 addition & 1 deletion cg/constants/scout_upload.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from cg.utils.enums import StrEnum
from enum import StrEnum


class GenomeBuild(StrEnum):
Expand Down
2 changes: 1 addition & 1 deletion cg/constants/sequencing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Constants related to sequencing."""
from cg.utils.enums import StrEnum
from enum import StrEnum


class Sequencers(StrEnum):
Expand Down
16 changes: 11 additions & 5 deletions cg/constants/subject.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
from enum import Enum, IntEnum
from enum import Enum, StrEnum, IntEnum


class Gender(str, Enum):
class Gender(StrEnum):
FEMALE = "female"
MALE = "male"
UNKNOWN = "unknown"
OTHER = "other"
MISSING = None
MISSING = ""

def __repr__(self):
return self.value


class PhenotypeStatus(str, Enum):
class PhenotypeStatus(StrEnum):
UNKNOWN = "unknown"
UNAFFECTED = "unaffected"
AFFECTED = "affected"
MISSING = None
MISSING = ""

def __repr__(self):
return self.value
Expand All @@ -33,6 +33,12 @@ class PlinkGender(str, Enum):
MALE = 1
FEMALE = 2

def __str__(self) -> str:
return str.__str__(self.value)


class RelationshipStatus(str, Enum):
HAS_NO_PARENT = 0

def __str__(self) -> str:
return str.__str__(self.value)
4 changes: 2 additions & 2 deletions cg/constants/tb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enum import Enum
from enum import StrEnum


class AnalysisStatus:
Expand All @@ -12,7 +12,7 @@ class AnalysisStatus:
QC: str = "qc"


class AnalysisTypes(str, Enum):
class AnalysisTypes(StrEnum):
WGS: str = "wgs"
WES: str = "wes"
TGS: str = "tgs"
Expand Down
4 changes: 2 additions & 2 deletions cg/meta/archive/ddn_dataflow.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Module for archiving and retrieving folders via DDN Dataflow."""
from datetime import datetime
from enum import Enum
from enum import StrEnum
from pathlib import Path
from typing import Optional
from urllib.parse import urljoin
Expand Down Expand Up @@ -28,7 +28,7 @@
SOURCE_ATTRIBUTE: str = "source"


class DataflowEndpoints(str, Enum):
class DataflowEndpoints(StrEnum):
"""Enum containing all DDN dataflow endpoints used."""

ARCHIVE_FILES = "files/archive"
Expand Down
2 changes: 1 addition & 1 deletion cg/models/orders/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from cg.constants.constants import Pipeline
from cg.utils.enums import StrEnum
from enum import StrEnum


class OrderType(StrEnum):
Expand Down
12 changes: 6 additions & 6 deletions cg/models/orders/sample_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enum import Enum
from enum import StrEnum
from typing import Optional

from pydantic import BaseModel, BeforeValidator, ConfigDict, constr
Expand All @@ -9,33 +9,33 @@
from cg.store.models import Application, Customer, Family, Pool, Sample


class ControlEnum(str, Enum):
class ControlEnum(StrEnum):
not_control = ""
positive = "positive"
negative = "negative"


class SexEnum(str, Enum):
class SexEnum(StrEnum):
male = "male"
female = "female"
unknown = "unknown"


class PriorityEnum(str, Enum):
class PriorityEnum(StrEnum):
research = "research"
standard = "standard"
priority = "priority"
express = "express"
clinical_trials = "clinical_trials"


class ContainerEnum(str, Enum):
class ContainerEnum(StrEnum):
no_container = "No container"
plate = "96 well plate"
tube = "Tube"


class StatusEnum(str, Enum):
class StatusEnum(StrEnum):
affected = "affected"
unaffected = "unaffected"
unknown = "unknown"
Expand Down
10 changes: 0 additions & 10 deletions cg/utils/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,5 @@
from enum import Enum


class StrEnum(str, Enum):
def __str__(self) -> str:
return str.__str__(self)


class ListEnum(list, Enum):
pass


class IntEnum(int, Enum):
def __int__(self) -> int:
return int.__int__(self)

0 comments on commit 0d4d035

Please sign in to comment.