Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

In general I agree with Raymond, although I am warmer to this feature. And I 
think we should have a mechanism to deprecate not only options, but subcommands.

* The warnings module is used for warning about the use of API. It outputs the 
file and the line number of the caller to help the developer to fix his code. 
It allows to hide warnings from non-developers.

But warnings about deprecated CLI options and commands are purposed to be shown 
to the user of the CLI. They should not contain references to source code, 
because it is not the cause of the warning. The argparse module should use the 
same mechanism for warnings and errors: output to stderr.

* I do not understand the purpose of deprecated_pending. The feature is either 
deprecated or not. If it is deprecated, using it will produce a warning. If it 
is not deprecated -- no warning. In case of silent deprecation you can manually 
add a note in the help.

* I am not sure about deprecated_reason. We do not have a way to specify error 
message for standard errors (such like about missed required argument). If you 
need a custom warning, do not use the standard deprecation mechanism and emits 
a warning manually.

* As for moving the output of a warning to post-parsing logic, this is not 
always convenient and possible.

Let you have options "--verbose" which increments the verbosity level and 
"--verbosity-level" which sets it directly. One of them is deprecated. We can't 
easily use a post-parsing logic because they set the same destination. In this 
case we can workaround this by rewriting the logic to use different 
destinations, but there this is not always possible. Imagine you have options 
--add and --append which append the argument to the list and want to deprecate 
one of them. You can't use different lists and merge them in post-parsing, 
because the relative order matters.

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39467>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to