From 539778b22cd60715c14f6eecec751a3f92ce84ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Mon, 22 Sep 2025 15:14:34 -0600 Subject: [PATCH 1/2] Address Click 8.2+ deprecation warning by using type-checking imports --- .changes/unreleased/Fixes-20250922-151726.yaml | 6 ++++++ core/dbt/cli/options.py | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 .changes/unreleased/Fixes-20250922-151726.yaml 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 c73a4bcd374..285d1370b29 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: From 539b615aa1260e874cbb978ccb941987deeeac59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= Date: Fri, 31 Oct 2025 11:46:40 -0600 Subject: [PATCH 2/2] Add quotes to `Context` --- core/dbt/cli/options.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/dbt/cli/options.py b/core/dbt/cli/options.py index 2affe20f475..beb251814d2 100644 --- a/core/dbt/cli/options.py +++ b/core/dbt/cli/options.py @@ -35,7 +35,7 @@ def __init__(self, *args, **kwargs) -> None: else: assert isinstance(option_type, ChoiceTuple), msg - def add_to_parser(self, parser: "_OptionParser", ctx: Context): + 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