File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -558,8 +558,17 @@ def convert(
558558 if isinstance (value , ArtifactQuery ):
559559 return value
560560 try :
561+ # Handle datetime.date conversion for union types (e.g., Optional[datetime.date])
562+ target_type = self ._python_type
563+ if hasattr (self ._python_type , "__origin__" ) and self ._python_type .__origin__ is typing .Union :
564+ # For union types like Optional[datetime.date], extract the non-None type
565+ union_args = typing .get_args (self ._python_type )
566+ non_none_types = [arg for arg in union_args if arg is not type (None )]
567+ if len (non_none_types ) == 1 :
568+ target_type = non_none_types [0 ]
569+
561570 # If the expected Python type is datetime.date, adjust the value to date
562- if self . _python_type is datetime .date :
571+ if target_type is datetime .date :
563572 # Click produces datetime, so converting to date to avoid type mismatch error
564573 value = value .date ()
565574 # 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