from enum import Enum from typing import List from image_prediction.formatter.formatter import Formatter class EnumFormatter(Formatter): @staticmethod def __format(metadata: dict): return {key.value if isinstance(key, Enum) else key: val for key, val in metadata.items()} def format(self, metadata: List[dict]): return map(self.__format, metadata)