<#5904 [BUG] `EnumTransformer` throws `TypeError` ...
# flytekit
c
#5904 [BUG] `EnumTransformer` throws `TypeError` with Python 3.11 Issue created by linhai-fn Describe the bug
EnumTransformer
throws the following error when using Python 3.11: File /fn/lib/python3.11/enum.py:742, in EnumType.__contains__(cls, member) 735 import warnings 736 warnings.warn( 737 "in 3.12 contains will no longer raise TypeError, but will return True or\n" 738 "False depending on whether the value is a member or the value of a member", 739 DeprecationWarning, 740 stacklevel=2, 741 ) --> 742 raise TypeError( 743 "unsupported operand type(s) for 'in': '%s' and '%s'" % ( 744 type(member).qualname, cls.class.qualname)) 745 return isinstance(member, cls) and member.name in cls._member_map_ TypeError: unsupported operand type(s) for 'in': 'str' and 'EnumType' The reason is due to these two lines in the `assert_type`: ... val = v.value if isinstance(v, enum.Enum) else v if val not in t: ... The following code returns
True
in python 3.12. But will throw an
TypeError
in python 3.11 as described above. from enum import Enum class TestEnum(Enum): TEST = "Test" TestEnum.TEST.value in TestEnum Expected behavior
EnumTransformer
shouldn't throw a TypeError when checking if a value is a member of an Enum. Additional context to reproduce No response Screenshots No response Are you sure this issue hasn't been raised already? • Yes Have you read the Code of Conduct? • Yes flyteorg/flyte