Skip to content

Commit

Permalink
fix: Make FlyteFile compatible with Annotated[..., HashMethod]
Browse files Browse the repository at this point in the history
See issue #3424
  • Loading branch information
AdrianoKF committed Mar 9, 2023
1 parent be24c52 commit 7cbd2b8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions flytekit/types/file/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ def to_literal(
if python_val is None:
raise TypeTransformerFailedError("None value cannot be converted to a file.")

# Correctly handle `Annotated[FlyteFile, ...]` by extracting the origin type
if typing.get_origin(python_type) is typing.Annotated:
python_type = typing.get_args(python_type)[0]

if not (python_type is os.PathLike or issubclass(python_type, FlyteFile)):
raise ValueError(f"Incorrect type {python_type}, must be either a FlyteFile or os.PathLike")

Expand Down

0 comments on commit 7cbd2b8

Please sign in to comment.