alert_category.py (558B)
1 from enum import Enum 2 3 4 class AlertCategory(Enum): 5 HIGH = 1 6 LOW = 2 7 CUSTOM = 3 8 9 @staticmethod 10 def from_str( 11 category: str, 12 ): # It gets mad when I use the Type[AlertCategory] as a type hint 13 match category: 14 case "high_alert_button": 15 return AlertCategory.HIGH 16 case "low_alert_button": 17 return AlertCategory.LOW 18 case "sp_add_button": 19 return AlertCategory.CUSTOM 20 case _: 21 return AlertCategory[category.upper()]