Skip to content

Commit

Permalink
Handle annotations and enums better in Config
Browse files Browse the repository at this point in the history
  • Loading branch information
arxyzan committed Aug 23, 2023
1 parent a7e7e2c commit dc8ee58
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions hezar/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ def __post_init__(self):
elif "name" not in self.__annotations__ and self.name is not None:
self.name: str = self.name

if self.config_type is not None and isinstance(self.config_type, Enum):
self.config_type: str = self.config_type.value
# Convert enums to values
for param, value in self.dict().items():
if isinstance(getattr(self, param), Enum):
setattr(self, param, getattr(self, param).value)

def __getitem__(self, item):
try:
Expand Down

0 comments on commit dc8ee58

Please sign in to comment.