22import typing as t
33
44import click
5- from click import Context
6- from click .parser import OptionParser , ParsingState
75
86from dbt .cli .option_types import ChoiceTuple
97
8+ if t .TYPE_CHECKING :
9+ from click import Context
10+ from click .parser import OptionParser , ParsingState
11+
1012
1113# Implementation from: https://stackoverflow.com/a/48394004
1214# Note MultiOption options must be specified with type=tuple or type=ChoiceTuple (https://github.com/pallets/click/issues/2012)
@@ -33,8 +35,8 @@ def __init__(self, *args, **kwargs) -> None:
3335 else :
3436 assert isinstance (option_type , ChoiceTuple ), msg
3537
36- def add_to_parser (self , parser : OptionParser , ctx : Context ):
37- def parser_process (value : str , state : ParsingState ):
38+ def add_to_parser (self , parser : " OptionParser" , ctx : " Context" ):
39+ def parser_process (value : str , state : " ParsingState" ):
3840 # method to hook to the parser.process
3941 done = False
4042 value_list = str .split (value , " " )
@@ -65,7 +67,7 @@ def parser_process(value: str, state: ParsingState):
6567 break
6668 return retval
6769
68- def type_cast_value (self , ctx : Context , value : t .Any ) -> t .Any :
70+ def type_cast_value (self , ctx : " Context" , value : t .Any ) -> t .Any :
6971 def flatten (data ):
7072 if isinstance (data , tuple ):
7173 for x in data :
0 commit comments