File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88import os
99import pathlib
1010import sys
11+ import types
1112import typing
1213import typing as t
1314from 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.
You can’t perform that action at this time.
0 commit comments