Skip to content

Commit fb0ac9a

Browse files
committed
enum.py: Restore compatibility with prev version.
Signed-off-by: Ihor Nehrutsa <[email protected]>
1 parent e6f7e9b commit fb0ac9a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

python-stdlib/enum/enum.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ def __ne__(self, other):
139139
return self._v != self._get_v(other)
140140

141141

142+
def enum(**kw_args): # `**kw_args` kept backwards compatible as in the Internet examples
143+
return Enum(kw_args)
144+
145+
142146
class Enum(dict):
143147
def __init__(self, arg=None, **kwargs):
144148
super().__init__()
@@ -214,6 +218,11 @@ def __dir__(self):
214218
#return list(set(data_keys + class_stuff + parent_attrs))
215219
return list(set(data_keys + class_stuff))
216220

221+
def __call__(self, value):
222+
if self.is_value(value):
223+
return value
224+
raise ValueError(_Err + f"{value}")
225+
217226

218227
if __name__ == "__main__":
219228
# --- Usage Examples ---

0 commit comments

Comments
 (0)