Skip to content

Commit

Permalink
Use StrEnum instead of dual inheritance
Browse files Browse the repository at this point in the history
Rather than inheriting from `str, Enum`, use the `StrEnum` parent
class, which does the same thing more thoroughly.
  • Loading branch information
rra committed Dec 20, 2024
1 parent 1982889 commit 6b94864
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions client/src/rubin/nublado/client/models/_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from __future__ import annotations

from abc import ABCMeta, abstractmethod
from enum import Enum
from enum import Enum, StrEnum
from typing import Literal, override

from pydantic import BaseModel, Field


class NubladoImageClass(str, Enum):
class NubladoImageClass(StrEnum):
"""Possible ways of selecting an image."""

__slots__ = ()
Expand Down
6 changes: 3 additions & 3 deletions controller/src/controller/models/domain/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from dataclasses import dataclass
from enum import Enum
from enum import Enum, StrEnum
from typing import Annotated, Any, Protocol, Self, override

from kubernetes_asyncio.client import (
Expand Down Expand Up @@ -599,7 +599,7 @@ def to_kubernetes(self) -> V1Affinity:
)


class PodPhase(str, Enum):
class PodPhase(StrEnum):
"""One of the valid phases reported in the status section of a Pod."""

PENDING = "Pending"
Expand Down Expand Up @@ -759,7 +759,7 @@ def to_kubernetes(self) -> V1Toleration:
)


class VolumeAccessMode(str, Enum):
class VolumeAccessMode(StrEnum):
"""Access mode for a persistent volume.
The access modes ``ReadWriteOnce`` and ``ReadWriteOncePod`` are valid
Expand Down
4 changes: 2 additions & 2 deletions controller/src/controller/models/v1/lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from enum import Enum
from enum import Enum, StrEnum
from typing import Annotated, Any, Self

from kubernetes_asyncio.client import V1ResourceRequirements
Expand Down Expand Up @@ -35,7 +35,7 @@
]


class LabSize(str, Enum):
class LabSize(StrEnum):
"""Allowable names for pod sizes.
Taken from `d20 creature sizes`_.
Expand Down
4 changes: 2 additions & 2 deletions spawner/src/rubin/nublado/spawner/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from __future__ import annotations

from dataclasses import dataclass
from enum import Enum
from enum import StrEnum

from httpx_sse import ServerSentEvent


class LabStatus(str, Enum):
class LabStatus(StrEnum):
"""Possible status conditions of a user's pod per the lab controller.
This is not directly equivalent to pod phases. It is instead intended to
Expand Down

0 comments on commit 6b94864

Please sign in to comment.