diff --git a/.changes/unreleased/Fixes-20250922-151726.yaml b/.changes/unreleased/Fixes-20250922-151726.yaml new file mode 100644 index 00000000000..b7692994cb8 --- /dev/null +++ b/.changes/unreleased/Fixes-20250922-151726.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Address Click 8.2+ deprecation warning +time: 2025-09-22T15:17:26.983151-06:00 +custom: + Author: edgarrmondragon + Issue: "12038" diff --git a/core/dbt/cli/options.py b/core/dbt/cli/options.py index 0299e581a07..beb251814d2 100644 --- a/core/dbt/cli/options.py +++ b/core/dbt/cli/options.py @@ -2,11 +2,13 @@ import typing as t import click -from click import Context -from click.parser import _OptionParser, _ParsingState from dbt.cli.option_types import ChoiceTuple +if t.TYPE_CHECKING: + from click import Context + from click.parser import _OptionParser, _ParsingState + # Implementation from: https://stackoverflow.com/a/48394004 # 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: else: assert isinstance(option_type, ChoiceTuple), msg - def add_to_parser(self, parser: _OptionParser, ctx: Context): - def parser_process(value: str, state: _ParsingState): + def add_to_parser(self, parser: "_OptionParser", ctx: "Context"): + def parser_process(value: str, state: "_ParsingState"): # method to hook to the parser.process done = False value_list = str.split(value, " ") @@ -65,7 +67,7 @@ def parser_process(value: str, state: _ParsingState): break return retval - def type_cast_value(self, ctx: Context, value: t.Any) -> t.Any: + def type_cast_value(self, ctx: "Context", value: t.Any) -> t.Any: def flatten(data): if isinstance(data, tuple): for x in data: