Skip to content

Commit d224534

Browse files
committed
new: add missing value support similar to basic enum
1 parent 62026a1 commit d224534

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

fast_enum/fastenum.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ def __delattr__(cls, item):
185185
super().__delattr__(item)
186186

187187
def __getitem__(cls, item):
188-
return getattr(cls, item)
188+
if hasattr(cls,'__missing__') and hasattr(cls,item):
189+
return getattr(cls, item)
190+
return cls.__missing__(item)
189191

190192
def has_value(cls, value):
191193
return value in cls._value_to_instance_map

0 commit comments

Comments
 (0)