Skip to content

@junhaoliao junhaoliao Jul 31, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of overriding individual classes' __str__ method, can we add a mixin like

class IntEnumStrMixin:
    """
    Delegates __str__ to int.__str__, matching the behavior of IntEnum
    in Python 3.11+.
    TODO: Remove this when our minimum supported Python version is 3.11+.
    """

    def __str__(self):
        return int.__str__(self.__getattribute__("value"))

class CompressionJobStatus(IntEnumStrMixin, IntEnum):
    PENDING = 0
    RUNNING = auto()
    SUCCEEDED = auto()
    FAILED = auto()

alternatively, we can also extend the IntEnum class into a custom class and let the existing enum classes extend from it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated my code. let me know if you agree with the current approach. If you don't see any issues, I will then update the PR description.

Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,36 @@ class CompressionJobStatus(IntEnum):
SUCCEEDED = auto()
FAILED = auto()

def __str__(self) -> str:
return str(self.value)
Comment thread
haiqi96 marked this conversation as resolved.
Resolved

def to_str(self) -> str:
return str(self.name)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

class CompressionJobCompletionStatus(IntEnum):
SUCCEEDED = 0
FAILED = auto()

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

def to_str(self) -> str:
return str(self.name)


class CompressionTaskStatus(IntEnum):
PENDING = 0
RUNNING = auto()
SUCCEEDED = auto()
FAILED = auto()

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

def to_str(self) -> str:
return str(self.name)


# When adding new states always add them to the end of this enum
# and make necessary changes in the UI, Query Scheduler, and Reducer
Expand Down