Skip to content

Commit 1757a6e

Browse files
committed
feedback from review
Signed-off-by: Blake <blaketastic2@gmail.com>
1 parent b2cf456 commit 1757a6e

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

flytekit/interaction/click_types.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import os
99
import pathlib
1010
import sys
11+
import types
1112
import typing
1213
import typing as t
1314
from typing import cast, get_args
@@ -585,7 +586,14 @@ def convert(
585586
return value
586587
try:
587588
# If the expected Python type is datetime.date, adjust the value to date
588-
if self._python_type is datetime.date and isinstance(value, datetime.datetime):
589+
is_union = typing.get_origin(self._python_type) in (
590+
typing.Union,
591+
types.UnionType,
592+
)
593+
args = typing.get_args(self._python_type)
594+
is_date_type = (is_union and datetime.date in args) or self._python_type is datetime.date
595+
596+
if is_date_type and isinstance(value, datetime.datetime):
589597
# Click produces datetime, so converting to date to avoid type mismatch error
590598
value = value.date()
591599
# If the input matches the default value in the launch plan, serialization can be skipped.

0 commit comments

Comments
 (0)