+1, but I would make "deprecated" either a warning, an exception or a
This way to create a simple deprecation, you just provide
DeprecationWarning('This will be gone in the next release'), or
ValueError('This has been removed in 2.X, use "stuff instead"') if you
decide it's gone for good. But if you need a custom behavior, you pass
in a callable.
Le 09/08/2017 à 09:56, Tarek Ziadé a écrit :
> I don't think there's any helper to deprecate an argument in argparse
> Let's say you have a --foo option in your CLI and want to deprecate it
> in the next release before you completely remove it later.
> My first though on how to do this by adding a new "deprecated" option to
> "deprecated" would be a callable that is called after the argument has
> been parsed by argparse,
> so the developer can decide if they want to issue a deprecation warning,
> use the parsed value or override it etc.
> Another interesting approach suggest by Doug Hellman, which I like as
> much, is a set of higher level options that
> provide a deprecation workflow for arguments, see
> What do you think?
Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/