question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The argument name in the deprecation warning message should use the format "--foo-bar" instead of "foo_bar"

See original GitHub issue

Related command

$ az aks create -g binxi1114 -n binxi111401 --enable-pod-security-policy -c 1
Argument 'enable_pod_security_policy' has been deprecated and will be removed in a future release.
Argument '--enable-pod-security-policy' is in preview and under development.

Extension name (the extension in question)

It’s not an issue to a specific extension. It is a common issue.

Description of issue (in as much detail as possible)

I’m working a PR to deprecate the argument ‘–enable-pod-security-policy’, and I get the message like below. The warning message should be “Argument ‘–enable-pod-security-policy’ has been deprecated and will be removed in a future release.”. Argument 'enable_pod_security_policy' is not good.

$ az aks create -g binxi1114 -n binxi111401 --enable-pod-security-policy -c 1
Argument 'enable_pod_security_policy' has been deprecated and will be removed in a future release.
Argument '--enable-pod-security-policy' is in preview and under development.

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jiaslicommented, Nov 15, 2022

It is the designed behavior of knack to show argument_dest in the warning message if deprecation target is not specified:

https://github.com/microsoft/knack/blob/cd590312b9b4ea1402d7a0a76814f6ca4da7fab8/knack/arguments.py#L221-L222

        if deprecate_info:
            deprecate_info.target = deprecate_info.target or argument_dest

To override the enable_pod_security_policy in the warning message, please specify

deprecate_info=c.deprecate(target='--enable-pod-security-policy')

Here is an example from resource command module:

https://github.com/Azure/azure-cli/blob/5b91300bb788d59683461b4570854c41dd8c3659/src/azure-cli/azure/cli/command_modules/resource/_params.py#L390-L391

Another example from vm command module:

https://github.com/Azure/azure-cli/blob/93b5083fe5d60bd29ff37ad3e1b32e8a600d3441/src/azure-cli/azure/cli/command_modules/vm/_params.py#L209-L210

1reaction
PramodValavala-MSFTcommented, Nov 15, 2022

@bingosummer Thanks for bringing this up! Looks like that is how it is handled in the knack framework (this code here) but looks like if you use the options_list parameter when defining the argument, it would be as expected.

Nonetheless, I believe showing the argument is not best for customers since that would just be confusing. @yonzhan @jiasli Could you share insights on why the default behavior is so?

Read more comments on GitHub >

github_iconTop Results From Across the Web

decorators in the python standard lib (@deprecated specifically)
import warnings import functools def deprecated(func): """This is a decorator which can be used to mark functions as deprecated. It will result in...
Read more >
Drupal deprecation policy | Core change policies
A @deprecated PHPdoc tag that indicates when the code was deprecated, when it will be removed, and what to use instead, and an...
Read more >
Python deprecation - DEV Community ‍ ‍
How do you fix this? One obvious quick fix is to write the deprecation warning and hardcode the deprecated class name. If there...
Read more >
The Straight Dope on Deprecations | Cloudbees Blog
A deprecation is a warning message that tells a user they're using some piece of code or interface that will go away soon....
Read more >
twisted.python.deprecate : API documentation
The deprecated attributes will issue a warning whenever they are accessed. If the attributes being deprecated are in the same module as the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found