Skip to content

Commit

Permalink
SNOW-1571918 Update deprecated usages to recommended ones (#1400)
Browse files Browse the repository at this point in the history
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/
  • Loading branch information
sfc-gh-fcampbell authored Aug 2, 2024
1 parent eb18f58 commit 3c95bb0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/snowflake/cli/api/commands/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion src/snowflake/cli/api/project/schemas/updatable_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3c95bb0

Please sign in to comment.