Skip to content

Commit

Permalink
Add another sample for user defined enum.
Browse files Browse the repository at this point in the history
  • Loading branch information
cdleary committed Apr 28, 2024
1 parent 12cd826 commit c9f8bf1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions py_samples/import_enum_and_print_udt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import enum

class MyEnum(enum.Enum):
MY = 'my'
ENUMERATED = 'enumerated'
ITEMS = 'items'


e = MyEnum.MY
assert e == MyEnum.MY
assert e == MyEnum('my')
assert e != MyEnum('enumerated')
assert isinstance(e, MyEnum), e

s = str(e)
assert s == 'MyEnum.MY', s
r = repr(e)
assert r == "<MyEnum.MY: 'my'>", r
print(e)
1 change: 1 addition & 0 deletions src/echo/builtin_predicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def _do_bool_call(args: Tuple[Any, ...],
types.BuiltinFunctionType,
types.MethodDescriptorType,
getattr(_thread, 'RLock'), io.TextIOBase,
type(NotImplemented),
type(None), getattr(re, 'Match'))), \
(o, type(o))
return Result(bool(o))
Expand Down

0 comments on commit c9f8bf1

Please sign in to comment.