Skip to content

Commit

Permalink
fix(enum): using wrong class when finding value (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
portellaa authored Dec 21, 2022
1 parent 9d39ee9 commit 1459a55
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core/ydata/core/enum/string_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ def _missing_(cls, value):
if isinstance(value, str):
upper_value = value.upper()

key = StringEnum._key_from_str_(upper_value)
key = cls._key_from_str(upper_value)
if key is not None:
return key

lower_value = value.lower()

key = StringEnum._key_from_str_(lower_value)
key = cls._key_from_str(lower_value)
if key is not None:
return key

raise ValueError(f"{value} is not a valid {cls.__name__}")

@classmethod
def _key_from_str_(cls, value: str):
if value in cls.__members__:
return cls(value)
def _key_from_str(cls, value: str):
if value in cls._member_map_.keys():
return cls._member_map_[value]

return None

Expand Down

0 comments on commit 1459a55

Please sign in to comment.