Skip to content

Commit 6d3b2a1

Browse files
Address Click 8.2+ deprecation warning by using type-checking imports
1 parent faeee35 commit 6d3b2a1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

core/dbt/cli/options.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
import typing as t
33

44
import click
5-
from click import Context
6-
from click.parser import OptionParser, ParsingState
75

86
from 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

Comments
 (0)