[issue39467] Allow to deprecate CLI arguments in argparse

Raymond Hettinger report at bugs.python.org
Mon Jan 27 17:25:10 EST 2020


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

Will leave this open for a while so that many people can comment on the proposal before we act on it.

My initial take is:

* Having a way to deprecate seems useful.

* In practice, I haven't seen this done very much (in big tooling such as GCC perhaps, but everyday command-line tools don't seem to do this AFAICT).

* The warnings module is likely not the right implementation tool.  The warnings module doesn't make as much sense for CLIs as it does for libraries.  It particular, the warnings module is all about the ability of consumer code to filter, ignore, or escalate warnings.  Also, we've so far been good about minimizing inter-module dependencies so that start-up time remains fast.

* The PR is aggressive in providing *deprecated*, *deprecated_reason*, and *deprecated_pending*.  Perhaps a simpler hook or flag would suffice.  The overall module API is already large enough to be a barrier to learning all the features.

* There is some question as to whether this belongs in argparse at all or whether it should be in downstream, post-parsing logic.  For example:
     
    args = parser.parse_args()
    if args.throw:
         print('"throw" has been deprecated, use "toss" instead',
               file=sys.stderr)
    ..

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39467>
_______________________________________


More information about the Python-bugs-list mailing list