Skip to content

Commit

Permalink
use prior logic for 3.9
Browse files Browse the repository at this point in the history
Signed-off-by: Yee Hing Tong <[email protected]>
  • Loading branch information
wild-endeavor committed Oct 21, 2024
1 parent 903b071 commit 41b43c5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions flytekit/core/type_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,13 @@ def guess_python_type(self, literal_type: LiteralType) -> Type[enum.Enum]:
raise ValueError(f"Enum transformer cannot reverse {literal_type}")

def assert_type(self, t: Type[enum.Enum], v: T):
if sys.version_info < (3, 10):
if not isinstance(v, enum.Enum):
raise TypeTransformerFailedError(f"Value {v} needs to be an Enum in 3.9")
if not isinstance(v, t):
raise TypeTransformerFailedError(f"Value {v} is not in Enum {t}")
return

val = v.value if isinstance(v, enum.Enum) else v
if val not in t:
raise TypeTransformerFailedError(f"Value {v} is not in Enum {t}")
Expand Down

0 comments on commit 41b43c5

Please sign in to comment.