Skip to content

Commit

Permalink
fix: more stable typing introspection
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyworkman committed Dec 2, 2021
1 parent e9191a8 commit 235f01b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions flytekit/core/type_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ def get_transformer(cls, python_type: Type) -> TypeTransformer[T]:

# Handling of annotated generics, eg:
# typing.Annotated[typing.List[int], 'foo']
if isinstance(python_type, typing._AnnotatedAlias):
return cls.get_transformer(python_type.__origin__)
if typing.get_origin(python_type) is typing.Annotated:
return cls.get_transformer(typing.get_args(python_type)[0])

if python_type.__origin__ in cls._REGISTRY:
return cls._REGISTRY[python_type.__origin__]
Expand Down Expand Up @@ -449,8 +449,8 @@ def to_literal_type(cls, python_type: Type) -> LiteralType:
transformer = cls.get_transformer(python_type)
res = transformer.get_literal_type(python_type)
data = None
if hasattr(python_type, "__metadata__"):
for x in python_type.__metadata__:
if typing.get_origin(python_type) is typing.Annotated:
for x in typing.get_args(python_type)[1:]:
if not isinstance(x, FlyteAnnotation):
continue
if x.data.get("__consumed", False):
Expand Down

0 comments on commit 235f01b

Please sign in to comment.