Skip to content

Commit

Permalink
refactor: use built in StrEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
ShyAssassin committed Oct 16, 2023
1 parent a62d5dc commit 9f0e5c9
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions TrackingBackend/app/types.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
# This file exists purely because circular imports are a thing and im too lazy to come up with a better
# solution that doesnt involve a bunch of refactoring.
import enum
import logging
from enum import Enum
from enum import Enum, StrEnum
from dataclasses import dataclass


# When we upgrade to python 3.11 we can use the built in StrEnum
class StrEnum(str, enum.Enum):
def __new__(cls, value, *args, **kwargs):
if not isinstance(value, (str, enum.auto)):
raise TypeError(f"Values of StrEnums must be strings: {value!r} is a {type(value)}")
return super().__new__(cls, value, *args, **kwargs)

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

def _generate_next_value_(name, *_):
return name


class Algorithms(StrEnum):
HSF = "HSF"
BLOB = "BLOB"
Expand Down

0 comments on commit 9f0e5c9

Please sign in to comment.