Skip to content

Commit

Permalink
refactor: use StrEnum if available
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed Apr 10, 2024
1 parent 1bf0702 commit 5ad9b7a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions silverback/types.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
from enum import Enum
from typing import Optional, Protocol

from pydantic import BaseModel
from typing_extensions import Self # Introduced 3.11

try:
from enum import StrEnum # Only Python 3.11+

class TaskType(str, Enum):
except ImportError:
from enum import Enum

class StrEnum(str, Enum): # type: ignore[no-redef]
def __str__(self) -> str:
return self.value


class TaskType(StrEnum):
STARTUP = "silverback_startup" # TODO: Shorten
NEW_BLOCKS = "block"
EVENT_LOG = "event"
SHUTDOWN = "silverback_shutdown" # TODO: Shorten

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


class ISilverbackSettings(Protocol):
"""Loose approximation of silverback.settings.Settings. If you can, use the class as
Expand Down

0 comments on commit 5ad9b7a

Please sign in to comment.