mirror of
https://github.com/dbt-labs/dbt-core
synced 2025-12-17 19:31:34 +00:00
Address Click 8.2+ deprecation warning by using type-checking imports (#12039)
This commit is contained in:
committed by
GitHub
parent
bbd8fa02f1
commit
748d352b6b
6
.changes/unreleased/Fixes-20250922-151726.yaml
Normal file
6
.changes/unreleased/Fixes-20250922-151726.yaml
Normal file
@@ -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"
|
||||
@@ -2,11 +2,13 @@ import inspect
|
||||
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 @@ class MultiOption(click.Option):
|
||||
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 @@ class MultiOption(click.Option):
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user