@@ -700,16 +700,19 @@ def wrapper(**kwargs: Any) -> Any:
700700 update_wrapper (wrapper , callback )
701701 return wrapper
702702
703+
703704class UnionParamType (click .ParamType ):
704705 @property
705- def name (self ) -> str : # type: ignore
706- return ' | ' .join (_type .name for _type in self ._types )
706+ def name (self ) -> str : # type: ignore
707+ return " | " .join (_type .name for _type in self ._types )
707708
708709 def __init__ (self , types : List [click .ParamType ]):
709710 super ().__init__ ()
710711 self ._types = types
711712
712- def convert (self , value : Any , param : Optional [click .Parameter ], ctx : Optional [click .Context ]) -> Any :
713+ def convert (
714+ self , value : Any , param : Optional [click .Parameter ], ctx : Optional [click .Context ]
715+ ) -> Any :
713716 # *types, last = self._types
714717 error_messages = []
715718 for _type in self ._types :
@@ -719,7 +722,7 @@ def convert(self, value: Any, param: Optional[click.Parameter], ctx: Optional[cl
719722 print (type (e ))
720723 error_messages .append (str (e ))
721724 # return last.convert(value, param, ctx)
722- raise self .fail (' \n ' + ' \n but also\n ' .join (error_messages ), param , ctx )
725+ raise self .fail (" \n " + " \n but also\n " .join (error_messages ), param , ctx )
723726
724727
725728def get_click_type (
@@ -813,7 +816,10 @@ def get_click_type(
813816 case_sensitive = parameter_info .case_sensitive ,
814817 )
815818 elif get_origin (annotation ) is not None and is_union (get_origin (annotation )):
816- types = [get_click_type (annotation = arg , parameter_info = parameter_info ) for arg in get_args (annotation )]
819+ types = [
820+ get_click_type (annotation = arg , parameter_info = parameter_info )
821+ for arg in get_args (annotation )
822+ ]
817823 return UnionParamType (types )
818824 raise RuntimeError (f"Type not yet supported: { annotation } " ) # pragma: no cover
819825
@@ -866,7 +872,7 @@ def get_click_param(
866872 continue
867873 types .append (type_ )
868874 if len (types ) == 1 :
869- main_type , = types
875+ ( main_type ,) = types
870876 origin = get_origin (main_type )
871877 else :
872878 for type_ in get_args (main_type ):
0 commit comments