From 3c95bb0a27fdbe612de31bacefbbbc593a8521b9 Mon Sep 17 00:00:00 2001 From: Francois Campbell Date: Fri, 2 Aug 2024 10:24:49 -0400 Subject: [PATCH] SNOW-1571918 Update deprecated usages to recommended ones (#1400) Fixes warnings by updating uses of deprecated code: - Fixes a warning from `click` that `autocompletion` is deprecated: > DeprecationWarning: 'autocompletion' is renamed to 'shell_complete'. The old name is deprecated and will be removed in Click 8.1. See the docs about 'Parameter' for information about new behavior. _typer_param_setup_autocompletion_compat(self, autocompletion=autocompletion) - Fixes a warning from `pydantic` about a deprecated pattern: > PydanticDeprecatedSince20: Using extra keyword arguments on `Field` is deprecated and will be removed. Use `json_schema_extra` instead. (Extra keys: 'is_discriminator_field'). Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.8/migration/ --- src/snowflake/cli/api/commands/flags.py | 2 +- src/snowflake/cli/api/project/schemas/updatable_model.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/snowflake/cli/api/commands/flags.py b/src/snowflake/cli/api/commands/flags.py index e70678ad11..ecf036f299 100644 --- a/src/snowflake/cli/api/commands/flags.py +++ b/src/snowflake/cli/api/commands/flags.py @@ -163,7 +163,7 @@ def callback(value): ), show_default=False, rich_help_panel=_CONNECTION_SECTION, - autocompletion=lambda: list(get_all_connections()), + shell_complete=lambda _, __, ___: list(get_all_connections()), ) TemporaryConnectionOption = typer.Option( diff --git a/src/snowflake/cli/api/project/schemas/updatable_model.py b/src/snowflake/cli/api/project/schemas/updatable_model.py index 56b4445bbd..22bba7969e 100644 --- a/src/snowflake/cli/api/project/schemas/updatable_model.py +++ b/src/snowflake/cli/api/project/schemas/updatable_model.py @@ -187,7 +187,8 @@ def DiscriminatorField(*args, **kwargs): # noqa N802 When this `DiscriminatorField` is used on a pydantic attribute, we will not allow templating on it. """ - return Field(is_discriminator_field=True, *args, **kwargs) + extra = dict(is_discriminator_field=True) + return Field(json_schema_extra=extra, *args, **kwargs) def IdentifierField(*args, **kwargs): # noqa N802